Hello, and thanks in advance for you time.
I am trying to filter out certain types of playlists for an iphone app (genius and On-the-go, specifically). the documentation says that the property attribute MPMediaPlaylistPropertyPlaylistAttributes will return the attributes associated with a playlist in the form of an NSNumber containing an NSInteger object. The documentation also lists these possible values for that property:
e
num {
MPMediaPlaylistAttributeNone = 0,
MPMediaPlaylistAttributeOnTheGo = (1 << 0),
MPMediaPlaylistAttributeSmart = (1 << 1),
MPMediaPlaylistAttributeGenius = (1 << 2)
};
typedef NSInteger MPMediaPlaylistAttribute;
I want to log the value to the terminal, so i used
NSLog(@"playlist attribute value:%@", [[playlist valueForProperty:MPMediaPlaylistPropertyPlaylistAttributes] stringValue]);
However, it prints out a value of 0 every time. This means that either every playlist has the attribute "MPMediaPlaylistAttributeNone", but this doesnt make sense since it is going through many genius and on the go playlists as well.
here is my entire code:
MPMediaQuery *myPlaylistsQuery = [MPMediaQuery playlistsQuery];
NSLog(@"number of playlists total:%d", [[myPlaylistsQuery collections] count]);
NSArray *playlists = [myPlaylistsQuery collections];
for (MPMediaPlaylist *playlist in playlists) {
NSInteger theAttributes;
theAttributes = [[playlist valueForProperty:MPMediaPlaylistPropertyPlaylistAttributes] integerValue];
NSLog(@"attribute:%d of playlist:%@", theAttributes, [playlist valueForProperty:MPMediaPlaylistPropertyName]);
}
and here is the result, when i run the application on my iphone. many of these playlists are in fact genius playlists:
attribute:0 of playlist:Purchased
attribute:0 of playlist:Purchased on My iPhone
attribute:0 of playlist:Army of Them
attribute:0 of playlist:Blue
attribute:0 of playlist:Closer
attribute:0 of playlist:Crazy
attribute:0 of playlist:Mad About You
attribute:0 of playlist:Midnight
attribute:0 of playlist:Something Elephants
attribute:0 of playlist:Supermassive Black Hole
attribute:0 of playlist:Take Me Away
attribute:0 of playlist:The Mixed Tape
attribute:0 of playlist:Time
attribute:0 of playlist:All Around Me
attribute:0 of playlist:anna's cd
attribute:0 of playlist:Av
attribute:0 of playlist:av 2
attribute:0 of playlist:Believe
attribute:0 of playlist:BH
attribute:0 of playlist:Boulevard of Broken Dreams
attribute:0 of playlist:car 1
attribute:0 of playlist:car 2
attribute:0 of playlist:car 3
Any ideas why every playlist is coming out as having 0 for the attributes?
Again, thanks for your time!