Next and previous default video controls with AVPlayerViewController - AVQueuePlayer not working

I have a list of songs to play in an AVPlayerViewController, so I am using AVQueuePlayer to play it. All songs are stored in the kit.


Now on the default screen I get the following functions:

  • Play / Pause
  • Automatically switch to the next video after completing the previous one
  • Fast forward the current video ('→ |')
  • Fast backward current video ('| <<')


What is not required should :

  • Previous functionality with provided '| <<to go to the previous video.
  • The following functionality with the provided "→ |" to go to the next video.


This I have done so far -

var arrAVPlayerItems = [AVPlayerItem]()
     for i in 1...4 {
         let fileURL = Bundle.main.url(forResource: "sample-\(i)", withExtension: "mp4")
         arrAVPlayerItems.append(AVPlayerItem(url: fileURL!))
     }
     let player = AVQueuePlayer(items: arrAVPlayerItems)
     playerViewController = AVPlayerViewController()
     playerViewController.player = player
     playerViewController.showsPlaybackControls = true

      


The situation here is that I will only have to use the default controls and not create my own.
Thanks in advance.

+3


source to share





All Articles