I\'m trying to play video with the following code:
UIGraphicsBeginImageContext(CGSizeMake(1,1));
self.player = [[MPMoviePlayerViewController alloc] initWith
If the video plays on your desktop machine, but not iOS (either in-app or in Safari), it's most likely because the HTTP server does not support byte-range requests. If the HTTP server does not support byte-range requests, iOS will not play the video. This differs from Safari on OS X, which plays the video regardless.
From the Safari Web Content Documentation:
HTTP servers hosting media files for iOS must support byte-range requests, which iOS uses to perform random access in media playback. (Byte-range support is also known as content-range or partial-range support.) Most, but not all, HTTP 1.1 servers already support byte-range requests.
Also, the HTTP server must provide a valid Content-Type
header (the URL above also enumerates the valid MIME types). iOS will not play the video if the MIME type is invalid or missing.
Try insert this:
[[NSNotificationCenter defaultCenter] removeObserver: self.player
name: MPMoviePlayerPlaybackDidFinishNotification
object: self.player.moviePlayer];
before
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishPlayback:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.player.moviePlayer];
I'am not sure why, but with remote url's I realized in a past project that you need to add the observer without object as reference.... If you ask me why, I am not sure. Try adding the observer with nil as object...
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];