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
|
||||
{
|
||||
[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"]) {
|
||||
[scrobbler start:pe];
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
NSString *endian;
|
||||
|
||||
BOOL seekable;
|
||||
|
||||
BOOL metadataLoaded;
|
||||
}
|
||||
|
||||
+ (NSSet *)keyPathsForValuesAffectingDisplay;
|
||||
|
@ -91,4 +93,8 @@
|
|||
|
||||
@property BOOL seekable;
|
||||
|
||||
@property BOOL metadataLoaded;
|
||||
|
||||
- (void)setMetadata:(NSDictionary *)metadata;
|
||||
|
||||
@end
|
||||
|
|
|
@ -42,6 +42,8 @@
|
|||
|
||||
@synthesize seekable;
|
||||
|
||||
@synthesize metadataLoaded;
|
||||
|
||||
// The following read-only keys depend on the values of other properties
|
||||
|
||||
+ (NSSet *)keyPathsForValuesAffectingDisplay
|
||||
|
@ -182,4 +184,19 @@
|
|||
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
|
||||
|
|
|
@ -334,24 +334,6 @@
|
|||
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
|
||||
ofObject:(id)object
|
||||
change:(NSDictionary *)change
|
||||
|
@ -362,7 +344,11 @@
|
|||
{
|
||||
// stop observing
|
||||
[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
|
||||
|
|
Loading…
Reference in New Issue