I'm trying to MPMoviePlayerController as subview on a view, but i'm trying to do that with Swift, this is what I did so far:
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let moviePath = NSBundle.mainBundle().pathForResource("splash", ofType: "mp4")
let movieURL = NSURL.fileURLWithPath(moviePath!)
let moviePlayer = MPMoviePlayerController(contentURL: movieURL)
NSNotificationCenter.defaultCenter().addObserver(self, selector: "moviePlayerDidFinishPlaying:" , name: MPMoviePlayerPlaybackDidFinishNotification, object: moviePlayer)
moviePlayer.controlStyle = .None
moviePlayer.scalingMode = .Fill
self.view.addSubview(moviePlayer.view)
moviePlayer.setFullscreen(true, animated: true)
moviePlayer.play()
}
func moviePlayerDidFinishPlaying(notification: NSNotification) {
}
It's not working, what am I doing wrong here?
You maybe forget add your resources as "Bundle Resources" Follow below step to add:
After that I think you can get your code working fine.