Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange behavior of MPMusicPlayerController.currentPlaybackTime

While a song is being played, I tried to get currentPlaybackTime.

        NSLog(@"Playback: %f", appDelegate.appMusicPlayer.currentPlaybackTime);

I always got "Playback: nan". The application gets the currentPlaybackTime correctly when running (not debugging). The LLDB debugger also gives the correct currentPlaybackTime.

Does anyone know what going on with this property?

like image 899
NorThanapon Avatar asked Nov 14 '11 07:11

NorThanapon


1 Answers

I would have commented on this but since I don't have enough reputation to do so... According to this solution (I know, it's for MPMoviePlayerController but since both conform to the MPMediaPlayback Protocol this may be useful):

https://stackoverflow.com/a/10652551/3374794

You'll probably have to wait 1ms (1/1000 s) for the player to (?load?) the item.

MPMediaPlayBack Protocol Reference

like image 168
tomalbrc Avatar answered Oct 19 '22 18:10

tomalbrc