I have this code but it doesn't show anything only a black frame.
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
var filepath: NSString = NSBundle.mainBundle().pathForResource("Akbar_ipad", ofType: "mp4")
var fileURL: NSURL = NSURL(string: filepath)
let moviePlayerController = MPMoviePlayerController(contentURL: fileURL)
moviePlayerController.shouldAutoplay = true
moviePlayerController.movieSourceType = MPMovieSourceType.File
moviePlayerController.view.frame = CGRect(x: 200, y: 200, width: 500, height: 300)
self.view.addSubview(moviePlayerController.view)
moviePlayerController.prepareToPlay()
moviePlayerController.play()
...
Have you got any idea how can i solve my problem? I am going crazy!
Thanks for your time.
I have a similar problem: How to load MPMoviePlayerController contentUrl asynchronous when loading view?
But here some ideas for you:
Maybe the url is constructed incorrectly/not local. Try using: let fileURL = NSBundle.mainBundle().URLForResource("Akbar_ipad", withExtension: "mp4")
You might need a global variable to hold a reference to the movie player instance (as described in the documentation.