Search code examples
iphoneuiwebviewyoutubempmovieplayercontrollerstreaming-video

Pros and cons of MPMoviePlayerController versus launching UIWebView to stream movie


I have a client who has video content for the web in Flash format. My task is to help them show the videos in an iPhone app.

I realize that step one is to get these videos into the appropriate Quicktime format for the iPhone.

Then I'm going to have to help the client figure out how or where to host these files. If that's tricky I assume they can be hosted at YouTube.

My chief concern, though, is which approach to take to stream the video. What are the pros and cons of MPMoviePlayerController versus launching UIWebView with the URL of the stream? Is there any difference? Is one of them more or less forgiving? Is one of them a better user experience? Any gotchas I might expect to run into?

I'm assuming playing video is pretty easy on the iPhone. Is it reasonable to try both and have one available as a fallback, or would that be a waste of time? I'm trying to schedule this out a bit, so I'd love to hear real-world experiences from anyone who's done this.


Solution

  • UIWebView cannot actually play videos. Navigating to a Youtube page with a UIWebview will simply launch the iPhone's Youtube App. Doing this a certain way will return control to your app after the video is played. See here: http://iphoneincubator.com/blog/tag/uiwebview

    I would recommend using MPMoviePlayer Controller, as long as you are only doing simple streaming. Here's some sample code to get you started:

    NSString *url = @"http://www.example.com/path/to/movie.mp4";
    MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc]
                                            initWithContentURL:[NSURL URLWithString:url]];
    [moviePlayer play];