PlaylistEntry cleanup.
parent
9ce92f2ac1
commit
9e8173bc74
|
@ -42,9 +42,12 @@ typedef enum {
|
||||||
BOOL seekable;
|
BOOL seekable;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setMetadata: (NSDictionary *)m;
|
+ (NSSet *)keyPathsForValuesAffectingDisplay;
|
||||||
|
+ (NSSet *)keyPathsForValuesAffectingLength;
|
||||||
|
+ (NSSet *)keyPathsForValuesAffectingPath;
|
||||||
|
+ (NSSet *)keyPathsForValuesAffectingFilename;
|
||||||
|
|
||||||
- (void)readMetadataThread;
|
- (void)readMetadataThread;
|
||||||
- (void)setProperties: (NSDictionary *)p;
|
|
||||||
- (void)readPropertiesThread;
|
- (void)readPropertiesThread;
|
||||||
|
|
||||||
@property(readonly) NSString *display;
|
@property(readonly) NSString *display;
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
|
|
||||||
@synthesize artist;
|
@synthesize artist;
|
||||||
@synthesize album;
|
@synthesize album;
|
||||||
@synthesize title;
|
|
||||||
@synthesize genre;
|
@synthesize genre;
|
||||||
@synthesize year;
|
@synthesize year;
|
||||||
@synthesize track;
|
@synthesize track;
|
||||||
|
@ -35,21 +34,26 @@
|
||||||
|
|
||||||
@synthesize seekable;
|
@synthesize seekable;
|
||||||
|
|
||||||
+ (void)initialize {
|
// The following read-only keys depend on the values of other properties
|
||||||
[self setKeys:[NSArray arrayWithObjects:@"artist",@"title",nil] triggerChangeNotificationsForDependentKey:@"display"];
|
|
||||||
[self setKeys:[NSArray arrayWithObjects:@"totalFrames",nil] triggerChangeNotificationsForDependentKey:@"length"];
|
+ (NSSet *)keyPathsForValuesAffectingDisplay
|
||||||
[self setKeys:[NSArray arrayWithObjects:@"URL",nil] triggerChangeNotificationsForDependentKey:@"path"];
|
{
|
||||||
[self setKeys:[NSArray arrayWithObjects:@"URL",nil] triggerChangeNotificationsForDependentKey:@"filename"];
|
return [NSSet setWithObjects:@"artist",@"title",nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setProperties:(NSDictionary *)dict
|
+ (NSSet *)keyPathsForValuesAffectingLength
|
||||||
{
|
{
|
||||||
[self setTotalFrames: [[dict objectForKey:@"totalFrames" ] longLongValue]];
|
return [NSSet setWithObject:@"totalFrames"];
|
||||||
[self setBitrate: [[dict objectForKey:@"bitrate" ] intValue]];
|
}
|
||||||
[self setChannels: [[dict objectForKey:@"channels" ] intValue]];
|
|
||||||
[self setBitsPerSample: [[dict objectForKey:@"bitsPerSample" ] intValue]];
|
+ (NSSet *)keyPathsForValuesAffectingPath
|
||||||
[self setSampleRate: [[dict objectForKey:@"sampleRate" ] floatValue]];
|
{
|
||||||
[self setSeekable: [[dict objectForKey:@"seekable" ] boolValue]];
|
return [NSSet setWithObject:@"URL"];
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (NSSet *)keyPathsForValuesAffectingFilename
|
||||||
|
{
|
||||||
|
return [NSSet setWithObject:@"URL"];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)readPropertiesThread
|
- (void)readPropertiesThread
|
||||||
|
@ -62,32 +66,14 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self performSelectorOnMainThread:@selector(setProperties:) withObject:properties waitUntilDone:YES];
|
[self performSelectorOnMainThread:@selector(setValuesForKeysWithDictionary:) withObject:properties waitUntilDone:YES];
|
||||||
}
|
|
||||||
|
|
||||||
- (void)setMetadata: (NSDictionary *)m
|
|
||||||
{
|
|
||||||
NSString *ti = [m objectForKey:@"title"];
|
|
||||||
|
|
||||||
if (ti == nil || [ti isEqualToString:@""]) {
|
|
||||||
self.title = [[self.URL path] lastPathComponent];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
self.title = ti;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.artist = [m objectForKey:@"artist"];
|
|
||||||
self.album = [m objectForKey:@"album"];
|
|
||||||
self.genre = [m objectForKey:@"genre"];
|
|
||||||
self.year = [m objectForKey:@"year"];
|
|
||||||
self.track = [m objectForKey:@"track"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)readMetadataThread
|
- (void)readMetadataThread
|
||||||
{
|
{
|
||||||
NSDictionary *metadata = [AudioMetadataReader metadataForURL:self.URL];
|
NSDictionary *metadata = [AudioMetadataReader metadataForURL:self.URL];
|
||||||
|
|
||||||
[self performSelectorOnMainThread:@selector(setMetadata:) withObject:metadata waitUntilDone:YES];
|
[self performSelectorOnMainThread:@selector(setValuesForKeysWithDictionary:) withObject:metadata waitUntilDone:YES];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +91,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the URL if the title is blank
|
||||||
|
@synthesize title;
|
||||||
|
- (NSString *)title
|
||||||
|
{
|
||||||
|
if(self.URL && (title == nil || [title isEqualToString:@""]))
|
||||||
|
{
|
||||||
|
return [[self.URL path] lastPathComponent];
|
||||||
|
}
|
||||||
|
return [[title retain] autorelease];
|
||||||
|
}
|
||||||
|
|
||||||
@dynamic length;
|
@dynamic length;
|
||||||
- (NSNumber *)length
|
- (NSNumber *)length
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,6 +75,12 @@ static NSDictionary *importKeys;
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Length is no longer a dependent key
|
||||||
|
+ (NSSet *)keyPathsForValuesAffectingLength
|
||||||
|
{
|
||||||
|
return Nil;
|
||||||
|
}
|
||||||
|
|
||||||
@synthesize length;
|
@synthesize length;
|
||||||
|
|
||||||
@end
|
@end
|
Loading…
Reference in New Issue