I'm trying to play a video from bundle directory but I'm getting this error:
video[29054:2968406] [MediaRemote] [AVOutputContext] WARNING: AVF context unavailable for sharedAudioPresentationContex
This is my implementation:
import UIKit
import AVKit
import AVFoundation
class ViewController: UIViewController {
var playerVC = AVPlayerViewController()
var playerView = AVPlayer()
override func viewDidLoad() {
super.viewDidLoad()
self.playVideo()
}
func playVideo() {
let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last! as NSURL
guard let fileURL = documentsDirectory.appendingPathComponent("video.mp4") else{ return }
self.playerView = AVPlayer(url:fileURL as URL)
self.playerVC.player = playerView
self.view.addSubview(self.playerVC.view)
self.addChildViewController(self.playerVC)
playerView.play()
}
Any of you knows what I'm doing wrong?, I'll really appreciate your help.