Reputation: 1891
I have an MPMoviePlayer that won't play. I don't know what's wrong with my code. I'm positive that my fileUrl is there. Thanks for the responses in advance!
moviePlayer = MPMoviePlayerController(contentURL: fileUrl)
moviePlayer.prepareToPlay()
self.view.addSubview(moviePlayer.view)
moviePlayer.setFullscreen(true, animated: true)
moviePlayer.play()
Upvotes: 0
Views: 315
Reputation: 3396
I hope your fileUrl is correct try this,
Declare moviePlayer outside func viewDidLoad()
var moviePlayer = MPMoviePlayerController()
To test put this code in 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
Upvotes: 1