1

I am creating a Monotouch iPhone app that will display streaming videos. I have been able to get the MPMoviePlayerController working with a local file (NSUrl FromFile), but have not been able to get videos streamed from a media server.

Here is the code I am using to play the video:

                string url = @"http://testhost.com/test.mp4";
                var nsurl = NSUrl.FromString(url);
                mp = new MPMoviePlayerController(nsurl);
                mp.SourceType = MPMovieSourceType.Streaming;

                //enable AirPlay
                //mp.AllowsAirPlay = true;

                //Add the MPMoviePlayerController View
                this.View.AddSubview(mp.View);

                //set the view to be full screen and show animated
                mp.SetFullscreen(true, true);

                //MPMoviePlayer must be set to PrepareToPlay before playback
                mp.PrepareToPlay();

                //Play Movie
                mp.Play();

Is there something else in implementing the MPMoviePlayerController for video streaming that I am missing? I also read that videos for iOS should be streamed using Apple's HTTP Live Streaming on the media server, is that a requirement? I have never worked with video streaming on an iOS device before so I am not sure if there is something lacking in my code or the media server setup or a combination.

1 Answer 1

0

I'm pretty sure you need a streaming server to use a video file from an HTTP url. However it's a requirement for applications (on the AppStore) to do so:

Important iPhone and iPad apps that send large amounts of audio or video data over cellular networks are required to use HTTP Live Streaming. See “Requirements for Apps.”

The good news is that your existing code should not have to be changed to handle this (it's server, not client side).

3
  • 1
    This would be the more exact, relevant part: If your app delivers video over cellular networks, and the video exceeds either 10 minutes duration or 5 MB of data in a five minute period, you are required to use HTTP Live Streaming. (Progressive download may be used for smaller clips.)
    – Till
    Sep 14, 2012 at 21:35
  • 1
    And no, you do not need a streaming server to play video over HTTP. If you do not provide an M3U8, a progressive download will happen.
    – Till
    Sep 14, 2012 at 21:36
  • After using a sample media file served from Apple, I was able to confirm the code does work. Thanks. Sep 17, 2012 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.