MPMoviePlayerViewController后台返回后黑屏

MPMoviePlayerViewController black screen after returning from background

我有一个简单的控制器,打开后可以播放视频。这行得通,但是当我将应用程序置于后台并 return 我得到一个空白或黑屏。如果我随后导航到另一个视图,然后 return,该视图不再是黑色并且正在播放视频。

如何在后台播放 return 视频?

MyViewController:

var myMovieController : MPMoviePlayerViewController?

override func viewDidLoad() {
    super.viewDidLoad()
    self.initMovie()
}

func  initMovie(){
    let moviePath = NSBundle.mainBundle().pathForResource("my-movie", ofType: "mp4")
    let movieURL = NSURL.fileURLWithPath(moviePath!)
    self.myMovieController = MPMoviePlayerViewController(contentURL: movieURL)
    self.myMovieController?.moviePlayer.view.frame = self.view.bounds
    self.myMovieController?.moviePlayer.controlStyle = MPMovieControlStyle.None
    self.myMovieController?.moviePlayer.prepareToPlay()
    self.myMovieController?.moviePlayer.scalingMode = .AspectFill
    self.myMovieController?.moviePlayer.fullscreen = true
    self.myMovieController?.moviePlayer.repeatMode = MPMovieRepeatMode.One
    self.view.insertSubview(myMovieController!.moviePlayer.view, atIndex:0)
    self.myMovieController?.moviePlayer.play()
}

在 applicationWillEnterForeground 中,我获得了对 MyViewController 的引用并调用了 myMovieController 上的播放。不确定这是否是正确的方法,但它似乎有效。

func applicationWillEnterForeground(application: UIApplication) {
    let mc: MyViewController = (window!.rootViewController as! MyViewController)
    mc.myMovieController?.moviePlayer.prepareToPlay()
    mc.myMovieController?.moviePlayer.play()
}