Search code examples
iosswiftmpmovieplayercontroller

Hiding video controls MPMoviePlayerController


I have referenced several responses to this same question but their solution does not work for me. I just wish to hide all user controls whilst watching video of local content. It faults on the line moviePlayer?.controlStyle = MPMovieControlStyleNone with error "Use of unresolved identifier for MPMovieControlStyleNone.

Here is my full block of code.

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.
    }
}

Solution

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