Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPMusicPlayerController Does Not Remember Playback Position

I'm making an app that will play audiobooks synced with iTunes. Is there a way my player can remember the playback position? Or do I need to implement this myself with some sort of database?

I'm testing on iOS 8.4

like image 593
Hackmodford Avatar asked Jul 11 '15 17:07

Hackmodford


People also ask

What are the modes of playback of the media player?

The current shuffle mode of the music player. The music player playback state modes. The repeat modes for the media player. The shuffle modes for the media player. Starts playback of the next media item in the playback queue; or, the music player is not playing, designates the next media item as the next to be played.

What is a music player?

An object used to play audio media items from the device's Music app library. Create an instance of a music player to play media items in your app. There are two types of music player: An application music player plays music locally within your app. It is not aware of the Music app’s now-playing item, nor does it affect the Music app’s state.

How does the system music player work?

The system music player employs the built-in Music app on your behalf. On instantiation, it takes on the current Music app state, such as the identification of the now-playing item. If a user switches away from your app while music is playing, that music continues to play.

What is playback queue in music player?

Before a music player can produce sound, it needs a playback queue. You provide the music player with its playback queue, which specifies the media items to be played. Sets a music player’s playback queue based on a media query. Sets a music player’s playback queue using a media item collection.


1 Answers

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

Here's an example:

[self.player setQueueWithItemCollection:self.collection];
self.player.currentPlaybackTime = [self.collection.items[0] bookmarkTime]; 
[self.player play];
like image 116
Hackmodford Avatar answered Sep 21 '22 14:09

Hackmodford