I am confused about this. I have an URL which contains a .m3u8 file in it and when I try to stream the URL with:
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[player setControlStyle:MPMovieControlModeVolumeOnly];
[player setFullscreen:YES];
[player prepareToPlay];
[player play];
It seems I can't because nothing starts playing. But when I use:
MPMoviePlayerViewController* controller = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
[self presentViewController:controller animated:YES completion:nil];
The viewcontroller
starts playing the file. What's the difference? Why can't I do it in my viewcontroller
?
Thanks in advance.
MPMoviePlayerController
lets you start playing, stopping and streaming of the content, which is meant to be incorporated into your own view hierarchy.
Since iOS 3.2 MPMoviePlayerViewController
became available, which handles the presentation for you.
In your code above, for the first case, it is not added to the view hierarchy.
Ex:
[self.view addSubview:player.view];
Another difference is MPMoviePlayerController
is a property of MPMoviePlayerViewController
.
Think of MPMoviePlayerController
as a player that gives you the controls and
MPMoviePlayerViewController
provides you, in addition to controls, also the presentation.
Hope this helps.