Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

xArtx

macrumors 6502a
Original poster
Mar 30, 2012
764
1
Hi Guys,

Above the timeline slider in the stock iPhone music player,
you see a feild something like "33 of 58" where 58 is the total number of tracks in the current playlist,
and 33 is the current index of the track playing.
(at least in the iPhone 5 media player "Now Playing" screen)

I would like to know how that information is retrieved.
I can't see it in mediaplayer documentation.
Thanks:)
Art.
 
Last edited:
Well the first part was easy:
Code:
itemindex = myPlayer.indexOfNowPlayingItem;

Now I have "33 of XX".

Just looking for the way to find the total number of tracks in the current playlist now..
 
Just so you know, the built in music player app is allowed to use private apis whereas your app is not... it's possible that it finds that number using private apis.

(I'm not saying that's the case, just letting you know that's a possibility... don't think that something must be possible within your own app just because a built in app can do it.)
 
Just so you know, the built in music player app is allowed to use private apis whereas your app is not... it's possible that it finds that number using private apis.

(I'm not saying that's the case, just letting you know that's a possibility... don't think that something must be possible within your own app just because a built in app can do it.)

It would be fine if the playlist was created in the app like the AddMusic sample.
I could just increment a counter as I cycled through the list array,
but I'm using the active playlist initiated by the stock music player.

I CAN cycle through all playlists and count the elements in each playlist,
but I don't yet know how to tell which playlist is active.
The joy!

edit.. also a possibility to turn on repeat, turn off shuffle, silently jump back to track index 0,
then jump back one more and get the total index from the last track in the playlist.
It just depends how slow that makes program launch if the playlist is large.


Images_zpsb40c000d.png
 
Last edited:
Hehe..

Code:
    nowPlayingItem = myPlayer.nowPlayingItem; // get intital info for comparison
    origindex = myPlayer.indexOfNowPlayingItem;
    ititleLabel = @" ";
    NSString *ititleString = [nowPlayingItem valueForProperty:MPMediaItemPropertyTitle];
    if (ititleString) {
    ititleLabel = [NSString stringWithFormat:@"%@",ititleString];
    } else {
    ititleLabel = @" ";
    }
        
        
        
        MPMediaQuery *myPlaylistsQuery = [MPMediaQuery playlistsQuery];
        NSArray *playlists = [myPlaylistsQuery collections];
        
        for (MPMediaPlaylist *playlist in playlists) {
            oitemcount = 0;
            
           MPMediaPlaylistPropertyName]);
            
            NSArray *songs = [playlist items];
            for (MPMediaItem *song in songs) {
                
                songTitle =
                [song valueForProperty: MPMediaItemPropertyTitle];
                
                if (oitemcount == origindex) {
                if ([ititleLabel isEqualToString:songTitle]) {playlistmatch = 1;}
                }
                
                oitemcount++;
            }
            
            if (playlistmatch == 1) {itemcount = oitemcount; playlistmatch = 0; showindex = 1;}
        }

if showindex = 1, a song title matching the nowplaying song title
was found in a playlist, and it also shares the same queue index!
In that case, the total tracks in the current playlist is in itemcount,
and show index is the flag to display the "currentindex of totalindex" info
:D
 
As much as it's going to be, but I can't edit the thread title
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.