我有一个无法播放的MPMoviePlayer。我不知道我的代码有什么问题。我很肯定我的fileUrl就在那里。感谢您提前回复!
moviePlayer = MPMoviePlayerController(contentURL: fileUrl)
moviePlayer.prepareToPlay()
self.view.addSubview(moviePlayer.view)
moviePlayer.setFullscreen(true, animated: true)
moviePlayer.play()
答案 0 :(得分:1)
我希望你的fileUrl是正确的尝试这个,
在func viewDidLoad()
之外声明moviePlayervar moviePlayer = MPMoviePlayerController()
测试将此代码放入func viewDidLoad()
中 moviePlayer = MPMoviePlayerController(contentURL:fileUrl)
moviePlayer.view.frame = UIScreen.mainScreen().bounds
self.view.addSubview(moviePlayer.view)
moviePlayer.setFullscreen(true, animated: true)
moviePlayer.prepareToPlay()
moviePlayer.play()
moviePlayer.controlStyle = MPMovieControlStyle.Embedded