Search code examples
c#iosxamarinxamarin.iosmpmovieplayercontroller

play mp4 movie with MPMoviePlayerController xamarin ios


i need to stream a movie in my ios app using MPMoviePlayerController.

this movie works fine:

moviePlayer = new MPMoviePlayerController(new NSUrl("http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"));
            View.AddSubview(moviePlayer.View);
            moviePlayer.SetFullscreen(true, true);
            moviePlayer.Play();

but this one does not work:

moviePlayer = new MPMoviePlayerController(new NSUrl("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"));
            View.AddSubview(moviePlayer.View);
            moviePlayer.SetFullscreen(true, true);
            moviePlayer.Play();

the official MPMoviePlayerController documentation, says that mp4 is supported too, so i don't know the reason why it doesn't work.

the device shows the player, but it doesn't start anything.

thanks in advance


Solution

  • Check your app output, I would assume you are getting the following message:

    App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.

    So, until you can get SSL-based mp4 streams for production, you can test by adding:

    <key>NSAppTransportSecurity</key>
    <dict>
      <!--Include to allow all connections (DANGER)-->
      <key>NSAllowsArbitraryLoads</key>
          <true/>
    </dict>
    

    Note: It is interesting that http-based .m3u8 playlists do not trigger "App Transport Security" errors but their underlaying transport stream fragments (.ts) will...