I am using an AVQueuePlayer
in my app. I have a two swipe gestures to skip to next and skip to previous avplayeritems. Right now to do skip to next I am just calling advanceToNextItem on the avqueueplayer which works well.
However the skip to previous I am removing all items and adding them back in with the previous video up front, this is really slow when skipping to previous multiple times. How can I make this faster just like calling advanceToNextItem
?
My code looks like this:
func skipToPrevious() {
queuePlayer.removeAllItems()
// move the previous playerItem to the front of the list then add them all back in
for playerItem in playerItems:
queuePlayer.insertItem(playerItem, afterItem: nil)
}