Reputation: 31
So far this is my attempt to have the lock screen display how much time has passed (elapsed) in the audio mp3 file and how much time in total the audio mp3 file is...
Here is my array of objects:
NSArray *madMoneyArray = [NSArray arrayWithObjects:[NSString stringWithFormat:@"Episode %d", a],
@"Jim Cramer",
@"Mad Money Podcast",
madMoneyArtwork,
[NSNumber numberWithFloat:(float)_audioPlayer.currentPlaybackTime],
[NSNumber numberWithDouble:(double)_audioPlayer.duration],
[NSNumber numberWithDouble:(double)1.0],
@"MadMoneyPodcast.png",
madMoneyURL, nil];
Here is my array of keys:
NSArray *array = [NSArray arrayWithObjects:MPMediaItemPropertyTitle,
MPMediaItemPropertyArtist,
MPMediaItemPropertyAlbumTitle,
MPMediaItemPropertyArtwork,
MPNowPlayingInfoPropertyElapsedPlaybackTime,
MPMediaItemPropertyPlaybackDuration,
MPNowPlayingInfoPropertyPlaybackRate, nil];
I successfully put the objects and their keys into the MPNowPlayingInfoCenter defaultCenter with this:
songInfo = [NSDictionary dictionaryWithObjects:[[_podcastArray objectAtIndex:(value - 1)] subarrayWithRange:NSMakeRange(0, imageIndex)] forKeys:_keys];
[[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo];
Where podcast array is where I hold several arrays with these objects and keys. Now when I go to the lock screen, everything I want to be shown is shown (i.e.: title, artist name, album name, album artwork). However, the one thing I can't get to show up is the stupid elapsed time and duration.
I have done a lot of research and implemented what I thought was the right thing to do, but apparently it isn't right/working.
I could really use some help here, thanks.
Upvotes: 3
Views: 734
Reputation: 1991
Your madMoneyArray has some extra values replace this array with this
NSArray *madMoneyArray = [NSArray arrayWithObjects:[NSString stringWithFormat:@"Episode %d", a],
@"Jim Cramer",
@"Mad Money Podcast",
madMoneyArtwork,
[NSNumber numberWithFloat:(float)_audioPlayer.currentPlaybackTime],
[NSNumber numberWithDouble:(double)_audioPlayer.duration],
[NSNumber numberWithInt:1],
nil];
try this , hope this helps !!!
Upvotes: 0
Reputation: 5205
Try replacing
[NSNumber numberWithFloat:(float)_audioPlayer.currentPlaybackTime]
with
[NSNumber numberWithDouble:_audioPlayer.currentPlaybackTime]
Also check that _audioPlayer.duration is not 0.
Upvotes: 1