我曾尝试使用下面的代码添加了一个视频我的观点:如何在点击播放时添加回调或获取通知?
let url = NSBundle.mainBundle().URLForResource("etude", withExtension:"mp4")
player = AVPlayer(URL: url!)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
playerViewController.view.frame = CGRect(x: xPos, y: yPos, width: videoWidth, height: videoHeight)
self.view.addSubview(playerViewController.view)
self.addChildViewController(playerViewController)
我当用户点击播放器上的播放按钮其他一些事件来触发。当发生这种情况时是否有一种很好的方式来设置回调,或者添加观察者来检测它?
NSBundle.mainBundle()有一个方法URLForResource(WithExtension :) –