I have a list of songs to play in AVPlayerViewController, so I use AVQueuePlayer to play it. All the songs are kept in the bundle.
Now, the default video screen I get the things functioning are:
- Play/Pause
- Auto switching to next video after completion of previous
- Fast forward the current video ('>>|')
- Fast backward the current video ('|<<')
The things not working which is needed must are:
- Previous functionality with the provided '|<<' control, to go to previous video.
- Next functionality with the provided '>>|' control, to go to 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 have to use only the default screen controls, and not make custom ones.
Thanks in advance.