Reputation: 14835
I have a large .m4v video file on an HTTP server. As an example, this is the URL I want to hit:
http://www.myurl.com/movies/video1.m4v
The video1.m4v file is 1GB in this example. When I load that URL in my Safari browser on my iPhone the file starts playing automatically and perfectly. I can skip ahead, go back, use Airplay, and everything works great and fast.
When I load it up on my iPhone with this code it just hangs on Loading
forever.
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:url];
[moviePlayerController.view setFrame:CGRectMake(0, 70, 320, 270)];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen = YES;
[moviePlayerController play];
What is the proper way to play an m4v file in my iOS app just like mobile Safari does? The main reason I want to do this is to hide the URL from the user and to not have the user experience of jumping in and out of my app.
Upvotes: 1
Views: 1406
Reputation: 2056
I'd try loading the video through a UIWebView.
UIWebView *webView = [[UIWebView alloc] init];
// Hide the webview from the user
webView.frame = CGRectZero;
[self addSubview:webView];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.myurl.com/movies/video1.m4v"]]];
Upvotes: 2