MPMoviePlayerController在全屏图像中几秒钟后冻结

时间:2015-06-08 22:22:22

标签: ios swift fullscreen mpmovieplayercontroller

我正在使用MPMoviePlayerController设置视频播放器。

我的应用程序是肖像,我希望视频是横向的,所以在我以模态方式呈现的viewController中强制旋转。但是当视频播放时,图像会在几秒钟后冻结,并且音频会继续运行。

仅当controlStyle为FullScreen时才会发生。

以下是我如何旋转视图:

override func shouldAutorotate() -> Bool {
    return false;
}

override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
    return UIInterfaceOrientation.LandscapeLeft
}

以及我如何调用视频播放器

func configureVideoPlayerAndPlay(){
    let path = NSBundle.mainBundle().pathForResource(videoName, ofType:"mp4")
    let url = NSURL.fileURLWithPath(path!)
    self.moviePlayer = MPMoviePlayerController(contentURL: url)
    if let player = self.moviePlayer {
        player.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.height, height: self.view.frame.size.width)
        player.view.sizeToFit()
        player.scalingMode = MPMovieScalingMode.AspectFit
        player.fullscreen = false
        player.controlStyle = MPMovieControlStyle.Fullscreen
        player.movieSourceType = MPMovieSourceType.File
        player.repeatMode = MPMovieRepeatMode.None
        player.play()
        self.view.addSubview(player.view)
    }

}

0 个答案:

没有答案