Re: iTunes Playlist Icons
Re: iTunes Playlist Icons
- Subject: Re: iTunes Playlist Icons
- From: "James B. Tuley" <email@hidden>
- Date: Sun, 10 Apr 2005 16:58:26 -0500
On Apr 9, 2005, at 9:11 PM, Dave DeLong wrote:
I've done something similar to this in another language, and here's
the gist of how I did it:
(I'm going to assume you're loading the iTunes Music Library.xml into
an NSDictionary, because that would be the smart thing to do)
You can loop through the playlists in the dictionary, and check if
each one contains a key of either "<key>Smart Info</key>" or
"<key>Smart Criteria</key>". If the playlist has either of those
keys, you can assume it's a Smart Playlist. If it doesn't, then you
check to see if the name is either "Library" (give it the Library
icon), "Party Shuffle" (give it the P.S. icon), or "Purchased Music"
(give it the green playlist icon). If it's not a smart playlist and
doesn't have any of those names, you can safely assume that's it's
just a standard drag-and-drop playlist.
I have a large .tiff file that has all of the standard iTunes playlist
and device icons at full 128x128 size, so if you want them, I can
email it privately.
HTH!
Dave DeLong
On Apr 9, 2005, at 3:39 PM, Jerry Brace wrote:
I'm populating a NSPopUpButton with a list of playlists from the
iTunes Library XML - finally figured it out :)
I was just wondering if anyone else here has done this - and if so -
how did you go about displaying the correct icon for each play list.
I know how to attach an image - but figuring out which one based on
the playlist type is the question.
For example there are these types: Library, Party Shuffled, Playlist,
Smart Playlist and Smart Playlist.
Would this have to be hard coded in some way? I was just wondering
what the best way to go about it would be.
Jerry Brace
Web and Multimedia Developer
email@hidden
I'm going to be rewriting my JTiTunesMusicLibrary class in the not too
distant future and releasing open source, but I'll share with you a
couple methods of what I do right now. I have a method called playlists
that just return the playlists as stored in inside iTunes Library XML,
and then I have a method prettyPlaylists, which identifies, tags, and
sorts the playlists structures so they are in the same order as iTunes.
I also have code that loads the the playlist icons dynamically from
iTunes but at this point I'm not ready to release.
Enjoy, feel free to use!
-Jay
http://indyjt.com
-(NSArray*)playlists{
return [[self libraryDictionary] objectForKey:@"Playlists"];
}
-(NSArray*)prettyPlaylists{
int i;
id tempPlaylists = [self playlists];
id tempTotal = [NSMutableArray array];
id tempSmart =[NSMutableArray array];
id tempNormal =[NSMutableArray array];
id tempMaster = [NSMutableArray array];
id tempPurchased = [NSMutableArray array];
id tempParty = [NSMutableArray array];
id tempSwitch = nil;
id nameDescriptor=[NSArray arrayWithObject:[[[NSSortDescriptor
alloc] initWithKey:@"Name"
ascending:YES] autorelease]];
for (i=0; i < [tempPlaylists count];i++){
id tempPlaylist = [tempPlaylists objectAtIndex:i];
id tempType = nil;
if ([[tempPlaylist objectForKey:@"Name"] isEqualTo:@"Party
Shuffle"]){
tempSwitch = tempParty;
tempType = @"Party";
}else if ([tempPlaylist objectForKey:@"Master"] != nil){
tempSwitch = tempMaster;
tempType = @"Master";
}else if ([tempPlaylist objectForKey:@"Purchased Music"] !=
nil){
tempSwitch = tempPurchased;
tempType = @"Purchased";
}else if ([tempPlaylist objectForKey:@"Smart Info"] != nil){
tempSwitch = tempSmart;
tempType = @"Smart";
} else {
tempSwitch = tempNormal;
tempType = @"Normal";
}
id tempDictionary = [[tempPlaylist mutableCopy] autorelease];
[tempDictionary setObject:tempType forKey:@"Type"];
[tempSwitch addObject:tempDictionary];
}
[tempTotal addObjectsFromArray:[tempMaster
sortedArrayUsingDescriptors:nameDescriptor]];
[tempTotal addObjectsFromArray:[tempParty
sortedArrayUsingDescriptors:nameDescriptor]];
[tempTotal addObjectsFromArray:[tempPurchased
sortedArrayUsingDescriptors:nameDescriptor]];
[tempTotal addObjectsFromArray:[tempSmart
sortedArrayUsingDescriptors:nameDescriptor]];
[tempTotal addObjectsFromArray:[tempNormal
sortedArrayUsingDescriptors:nameDescriptor]];
return tempTotal;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden