隐藏视频控件MPMoviePlayerController

时间:2014-10-23 07:22:11

标签: ios swift mpmovieplayercontroller

我已经引用了几个对同一问题的回答,但他们的解决方案对我不起作用。我只想在观看本地内容的视频时隐藏所有用户控件。它在moviePlayer上出现故障?.controlStyle = MPMovieControlStyleNone,错误“使用未解析的MPMovieControlStyleNone标识符。

这是我的完整代码块。

import UIKit
import MediaPlayer

var moviePlayer : MPMoviePlayerController?

class ViewController: UIViewController {

    func playVideo() {
        let path = NSBundle.mainBundle().pathForResource("IntroVideo", ofType: "mp4")
        let url = NSURL.fileURLWithPath(path!)
        moviePlayer = MPMoviePlayerController(contentURL: url)
        if let player = moviePlayer {
            player.view.frame = self.view.bounds
            moviePlayer?.controlStyle = MPMovieControlStyleNone
            player.prepareToPlay()
            player.scalingMode = .AspectFill
            self.view.addSubview(player.view)
        }
    }

    override func viewDidLoad() {
        super.viewDidLoad()        
        playVideo()       
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

4 个答案:

答案 0 :(得分:4)

moviePlayer!.controlStyle = MPMovieControlStyle.None for ios 8 and 9

答案 1 :(得分:2)

您可以在moviePlayer?.controlStyle = MPMovieControlStyleNone

之后删除player.controlStyle = .None并尝试使用player.scalingMode = .AspectFill.

这适用于iOS 7,但不适用于iOS 8。

答案 2 :(得分:1)

moviePlayer?.controlStyle = .None

答案 3 :(得分:0)

修复Fork项目并通过将controlStyle更改为“MPMovieControlStyleNone”来修复XCDYouTubeVideoPlayerViewController.h中的presentInView方法然后将你的git挂起到你的项目

这是最简单的方法:P