Fixed up metadata loading so metadata isn't always read when you play.
parent
d6a0b0670e
commit
7cbebef352
|
@ -51,7 +51,10 @@
|
||||||
|
|
||||||
- (void)performPlaybackDidBeginActions:(PlaylistEntry *)pe
|
- (void)performPlaybackDidBeginActions:(PlaylistEntry *)pe
|
||||||
{
|
{
|
||||||
[pe performSelectorOnMainThread:@selector(setValuesForKeysWithDictionary:) withObject:[playlistLoader readEntryInfo:pe] waitUntilDone:YES];
|
// Race here, but the worst that could happen is we re-read the data
|
||||||
|
if ([pe metadataLoaded] != YES) {
|
||||||
|
[pe performSelectorOnMainThread:@selector(setMetadata:) withObject:[playlistLoader readEntryInfo:pe] waitUntilDone:YES];
|
||||||
|
}
|
||||||
|
|
||||||
if([[NSUserDefaults standardUserDefaults] boolForKey:@"enableAudioScrobbler"]) {
|
if([[NSUserDefaults standardUserDefaults] boolForKey:@"enableAudioScrobbler"]) {
|
||||||
[scrobbler start:pe];
|
[scrobbler start:pe];
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
NSString *endian;
|
NSString *endian;
|
||||||
|
|
||||||
BOOL seekable;
|
BOOL seekable;
|
||||||
|
|
||||||
|
BOOL metadataLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSSet *)keyPathsForValuesAffectingDisplay;
|
+ (NSSet *)keyPathsForValuesAffectingDisplay;
|
||||||
|
@ -91,4 +93,8 @@
|
||||||
|
|
||||||
@property BOOL seekable;
|
@property BOOL seekable;
|
||||||
|
|
||||||
|
@property BOOL metadataLoaded;
|
||||||
|
|
||||||
|
- (void)setMetadata:(NSDictionary *)metadata;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -42,6 +42,8 @@
|
||||||
|
|
||||||
@synthesize seekable;
|
@synthesize seekable;
|
||||||
|
|
||||||
|
@synthesize metadataLoaded;
|
||||||
|
|
||||||
// The following read-only keys depend on the values of other properties
|
// The following read-only keys depend on the values of other properties
|
||||||
|
|
||||||
+ (NSSet *)keyPathsForValuesAffectingDisplay
|
+ (NSSet *)keyPathsForValuesAffectingDisplay
|
||||||
|
@ -182,4 +184,19 @@
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setMetadata:(NSDictionary *)metadata
|
||||||
|
{
|
||||||
|
if (metadata == nil)
|
||||||
|
{
|
||||||
|
self.error = YES;
|
||||||
|
self.errorMessage = @"Unable to retrieve metadata.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[self setValuesForKeysWithDictionary:metadata];
|
||||||
|
}
|
||||||
|
|
||||||
|
metadataLoaded = YES;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -334,24 +334,6 @@
|
||||||
return entryInfo;
|
return entryInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)processEntryInfo:(NSInvocationOperation *)operation
|
|
||||||
{
|
|
||||||
NSDictionary *entryInfo = [operation result];
|
|
||||||
PlaylistEntry *pe;
|
|
||||||
// get the playlist entry that the thread was inspecting
|
|
||||||
[[operation invocation] getArgument:&pe atIndex:2];
|
|
||||||
if (entryInfo == nil)
|
|
||||||
{
|
|
||||||
pe.error = YES;
|
|
||||||
pe.errorMessage = @"Unable to retrieve properties.";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
[pe setValuesForKeysWithDictionary:entryInfo];
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)observeValueForKeyPath:(NSString *)keyPath
|
- (void)observeValueForKeyPath:(NSString *)keyPath
|
||||||
ofObject:(id)object
|
ofObject:(id)object
|
||||||
change:(NSDictionary *)change
|
change:(NSDictionary *)change
|
||||||
|
@ -362,7 +344,11 @@
|
||||||
{
|
{
|
||||||
// stop observing
|
// stop observing
|
||||||
[object removeObserver:self forKeyPath:keyPath];
|
[object removeObserver:self forKeyPath:keyPath];
|
||||||
[self performSelectorOnMainThread:@selector(processEntryInfo:) withObject:object waitUntilDone:NO];
|
|
||||||
|
// get the playlist entry that the operation read for
|
||||||
|
PlaylistEntry *pe = nil;
|
||||||
|
[[object invocation] getArgument:&pe atIndex:2];
|
||||||
|
[pe performSelectorOnMainThread:@selector(setMetadata:) withObject:[object result] waitUntilDone:NO];
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue