我尝试将MPMoviePlayerController作为视图的子视图,但我试图用Swift做这个,这是我到目前为止所做的:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let moviePath = NSBundle.mainBundle().pathForResource("splash", ofType: "mp4")
let movieURL = NSURL.fileURLWithPath(moviePath!)
let moviePlayer = MPMoviePlayerController(contentURL: movieURL)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "moviePlayerDidFinishPlaying:" , name: MPMoviePlayerPlaybackDidFinishNotification, object: moviePlayer)
moviePlayer.controlStyle = .None
moviePlayer.scalingMode = .Fill
self.view.addSubview(moviePlayer.view)
moviePlayer.setFullscreen(true, animated: true)
moviePlayer.play()
}
func moviePlayerDidFinishPlaying(notification: NSNotification) {
}
它没有用,我在这里做错了什么?
答案 0 :(得分:1)
您可能会忘记添加资源作为"捆绑资源" 按照以下步骤添加:
之后我认为你可以让你的代码正常工作。