我在通过AVPlayer播放视频时遇到问题。出于某种原因,我收到错误'无法为类型' AVPlayer'调用初始化程序。使用类型'(URL:NSURL)'
的参数列表奇怪的是,这个确切的代码片段适用于我的另一个项目。我确实导入了AVKit和AVFoundation框架。
答案 0 :(得分:0)
var MoviePlaying:Bool = false
let path = NSBundle.mainBundle().pathForResource("big_buck_bunny_720p_50mb", ofType:"mp4")
var player: AVPlayer = AVPlayer()
let playerController = AVPlayerViewController()
@IBAction func PlayTapped(sender: UIButton) {
let moviePlayerController = AVPlayerViewController()
let path = NSBundle.mainBundle().pathForResource("big_buck_bunny_720p_50mb", ofType:"mp4")
let url = NSURL.fileURLWithPath(path!)
let playerVC = AVPlayerViewController()
var player: AVPlayer = AVPlayer()
playerVC.player = AVPlayer(URL: url)
self.presentViewController(playerVC, animated: true, completion: nil)