Url in your code:http://mywebsite.com/video.mp4
- not valid. With this url player produces an error like in your question. But if you try use another url (for example: http://nordenmovil.com/urrea/InstalaciondelavaboURREAbaja.mp4
- use it for test) your player will work without errors, but not correct. For correct work you must change your code:
add to your .h
file in @interface
section property (do not forget add @import MediaPlayer
):
@property (nonatomic, strong) MPMoviePlayerViewController *moviePlayer;
and change your code like below:
_moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:@"http://nordenmovil.com/urrea/InstalaciondelavaboURREAbaja.mp4"]];
_moviePlayer.view.frame = CGRectMake(0, 0, 500, 500);
_moviePlayer.moviePlayer.shouldAutoplay=YES;
_moviePlayer.moviePlayer.movieSourceType= MPMovieSourceTypeFile;
[_moviePlayer.moviePlayer setControlStyle:MPMovieControlStyleDefault];
[self.view addSubview:_moviePlayer.view];
[_moviePlayer.moviePlayer play];
As alternative you can use UIWebView
for play video:
NSURL *fileURL = [NSURL URLWithString:@"http://nordenmovil.com/urrea/InstalaciondelavaboURREAbaja.mp4"];
NSURLRequest* requestUrl = [[NSURLRequest alloc] initWithURL:fileURL];
UIWebView* webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
[self.view addSubview:webView];
[webView loadRequest:requestUrl];
If you will use UIWebView
for play video - try use your url and you will see what your link is wrong.