Question

This is a seemingly simple question that I just can't seem to find a simple answer for.

To rephrase the question: I want to get the current time stamp on a song playing on the native music player on an iPhone from my separate app.

I've seen the rich set of commands possible with MPMediaItemProperty but it seems nothing quite fits the bill.

MPMediaItemPropertyPlaybackDuration is close, but I believe this returns the total length of the currently playing song.

Any help is appreciated!

Matt

Was it helpful?

Solution

I believe you're looking for -[MPMusicPlayerController currentPlaybackTime];. This value returns the current position of the playhead, or rather the elapsed time in the currently playing track.

NSTimeInterval interval = [[MPMusicPlayerController iPodMusicPlayer] currentPlaybackTime];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top