Fixed serialization of FilePlaylistEntry; Added serialization and unserialization of album art
parent
66f3d69648
commit
1743016e71
|
@ -163,26 +163,32 @@ NSMutableDictionary * dictionaryWithPropertiesOfObject(id obj, NSArray * filterL
|
||||||
{
|
{
|
||||||
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
||||||
|
|
||||||
unsigned count;
|
Class class = [obj class];
|
||||||
objc_property_t *properties = class_copyPropertyList([obj class], &count);
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
do {
|
||||||
NSString *key = [NSString stringWithUTF8String:property_getName(properties[i])];
|
unsigned count;
|
||||||
if ([filterList containsObject:key]) continue;
|
objc_property_t *properties = class_copyPropertyList(class, &count);
|
||||||
|
|
||||||
Class classObject = NSClassFromString([key capitalizedString]);
|
for (int i = 0; i < count; i++) {
|
||||||
if (classObject) {
|
NSString *key = [NSString stringWithUTF8String:property_getName(properties[i])];
|
||||||
id subObj = dictionaryWithPropertiesOfObject([obj valueForKey:key], filterList);
|
if ([filterList containsObject:key]) continue;
|
||||||
[dict setObject:subObj forKey:key];
|
|
||||||
|
Class classObject = NSClassFromString([key capitalizedString]);
|
||||||
|
if (classObject) {
|
||||||
|
id subObj = dictionaryWithPropertiesOfObject([obj valueForKey:key], filterList);
|
||||||
|
[dict setObject:subObj forKey:key];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
id value = [obj valueForKey:key];
|
||||||
|
if(value) [dict setObject:value forKey:key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
id value = [obj valueForKey:key];
|
|
||||||
if(value) [dict setObject:value forKey:key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free(properties);
|
free(properties);
|
||||||
|
|
||||||
|
class = [class superclass];
|
||||||
|
} while (class);
|
||||||
|
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
@ -195,7 +201,7 @@ NSMutableDictionary * dictionaryWithPropertiesOfObject(id obj, NSArray * filterL
|
||||||
}
|
}
|
||||||
[fileHandle truncateFileAtOffset:0];
|
[fileHandle truncateFileAtOffset:0];
|
||||||
|
|
||||||
NSArray * filterList = [NSArray arrayWithObjects:@"display", @"length", @"path", @"filename", @"status", @"statusMessage", @"spam", @"stopAfter", @"shuffleIndex", @"index", @"current", @"queued", @"currentPosition", @"queuePosition", @"error", @"removed", @"url", nil];
|
NSArray * filterList = [NSArray arrayWithObjects:@"display", @"length", @"path", @"filename", @"status", @"statusMessage", @"spam", @"stopAfter", @"shuffleIndex", @"index", @"current", @"queued", @"currentPosition", @"queuePosition", @"error", @"removed", @"URL", nil];
|
||||||
|
|
||||||
NSMutableArray * topLevel = [[NSMutableArray alloc] init];
|
NSMutableArray * topLevel = [[NSMutableArray alloc] init];
|
||||||
|
|
||||||
|
@ -207,7 +213,37 @@ NSMutableDictionary * dictionaryWithPropertiesOfObject(id obj, NSArray * filterL
|
||||||
|
|
||||||
[dict setObject:path forKey:@"URL"];
|
[dict setObject:path forKey:@"URL"];
|
||||||
|
|
||||||
|
NSImage * image = [dict objectForKey:@"albumArt"];
|
||||||
|
if (image)
|
||||||
|
{
|
||||||
|
NSBitmapImageRep* requiredBitmap = nil;
|
||||||
|
BOOL setValue =NO;
|
||||||
|
|
||||||
|
for(NSBitmapImageRep* imagerep in [image representations])
|
||||||
|
{
|
||||||
|
if ([imagerep isKindOfClass:[NSBitmapImageRep class]])
|
||||||
|
{
|
||||||
|
if (!setValue) {
|
||||||
|
requiredBitmap = imagerep;
|
||||||
|
setValue =YES;
|
||||||
|
}
|
||||||
|
if ([requiredBitmap pixelsHigh]<[imagerep pixelsHigh]) {
|
||||||
|
requiredBitmap = imagerep;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[dict setObject:[requiredBitmap representationUsingType:NSJPEG2000FileType properties:nil] forKey:@"albumArt"];
|
||||||
|
|
||||||
|
[requiredBitmap release];
|
||||||
|
|
||||||
|
[image release];
|
||||||
|
}
|
||||||
|
|
||||||
[topLevel addObject:dict];
|
[topLevel addObject:dict];
|
||||||
|
|
||||||
|
[dict release];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSData * data = [NSPropertyListSerialization dataWithPropertyList:topLevel format:NSPropertyListXMLFormat_v1_0 options:0 error:0];
|
NSData * data = [NSPropertyListSerialization dataWithPropertyList:topLevel format:NSPropertyListXMLFormat_v1_0 options:0 error:0];
|
||||||
|
|
|
@ -87,6 +87,10 @@
|
||||||
|
|
||||||
[preparedEntry setObject:[self urlForPath:[preparedEntry objectForKey:@"URL"] relativeTo:filename] forKey:@"URL"];
|
[preparedEntry setObject:[self urlForPath:[preparedEntry objectForKey:@"URL"] relativeTo:filename] forKey:@"URL"];
|
||||||
|
|
||||||
|
NSData * data = [preparedEntry objectForKey:@"albumArt"];
|
||||||
|
if (data)
|
||||||
|
[preparedEntry setObject:[[[NSImage alloc] initWithData:data] autorelease] forKey:@"albumArt"];
|
||||||
|
|
||||||
[entries addObject:[NSDictionary dictionaryWithDictionary:preparedEntry]];
|
[entries addObject:[NSDictionary dictionaryWithDictionary:preparedEntry]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue