Reputation: 51
I am using code: video is not playing
moviePlayer = new MPMoviePlayerController(new NSUrl("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"));
//set appearance of video player
moviePlayer.View.Frame = new RectangleF(10, 80, 300, 200);
moviePlayer.View.BackgroundColor = UIColor.Clear;
moviePlayer.SourceType = MPMovieSourceType.File;
// Set this property True if you want the video to be auto played on page load
moviePlayer.ShouldAutoplay = true;
// If you want to keep the Video player on-ready-to-play state, then enable this
// This will keep the video content loaded from the URL, untill you play it.
moviePlayer.PrepareToPlay();
// Enable the embeded video controls of the Video Player, this has several types of Embedded controls for you to choose
moviePlayer.ControlStyle = MPMovieControlStyle.Default;
View.AddSubview(moviePlayer.View);
the moviePlayer
will play this video at this URL:
http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8
but not this one:
http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4
Upvotes: 1
Views: 724
Reputation: 9703
I ran your code and got this error:
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 I added this exception in the Info.plist :
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>clips.vorwaerts-gmbh.de</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
Think when you go to release your app you should aim to use https for all links.
Update Using MPMoviePlayerViewController
var moviePlayer = new MPMoviePlayerViewController(new NSUrl("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"));
//set appearance of video player
moviePlayer.View.Frame = new RectangleF(10, 80, 300, 200);
moviePlayer.View.BackgroundColor = UIColor.Blue;
moviePlayer.MoviePlayer.SourceType = MPMovieSourceType.File;
// Set this property True if you want the video to be auto played on page load
moviePlayer.MoviePlayer.ShouldAutoplay = true;
// If you want to keep the Video player on-ready-to-play state, then enable this
// This will keep the video content loaded from the URL, untill you play it.
moviePlayer.MoviePlayer.PrepareToPlay();
// Enable the embeded video controls of the Video Player, this has several types of Embedded controls for you to choose
moviePlayer.MoviePlayer.ControlStyle = MPMovieControlStyle.Default;
View.AddSubview(moviePlayer.View);
If this doesnt work then I would ask another question so others can see it.
Upvotes: 1