MPMusicPlayerController does not remember playback position

I am creating an application that will play audiobooks synchronized with iTunes. Is there a way my player can remember the playback position? Or do I need to implement this on my own with some kind of database?

I am testing iOS 8.4

+6
source share
2 answers

The key is to set the current playback time to the bookmark time of mpmediaitem before playback.

Here is an example:

[self.player setQueueWithItemCollection:self.collection]; self.player.currentPlaybackTime = [self.collection.items[0] bookmarkTime]; [self.player play]; 
+1
source

The audiobook file automatically remembers the playback position, and when asked to play it again, it resumes from that position - this is the built-in function of the Music application (now iBooks) and, therefore, MPMusicPlayerController.

However, you will notice that the Music application may lose track of the currently playing item (if the user restarts the device). And, of course, the user can manually change the current playable item.

Thus, if you want your application to return to what it was playing previously, you will need to save information about the current playback. And you can also save the current playback position, thereby making yourself even more reliable than the Music app.

0
source

All Articles