Reputation: 14453
How to play the video on iPhone using MonoTouch? I get the Video's from server as binary format and need to play that video's with all controls like pause, play, stop. How its possible?
Upvotes: 2
Views: 2266
Reputation: 706
You need to add the player's view to your view hierarchy. For example, assuming you had already added a view named _someView, you can add the MPMoviePlayerController's view like this:
UIView _someView;
MPMoviePlayerController _moviePlayer;
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
_someView = new UIView();
_someView.Frame = window.Bounds;
_moviePlayer = new MPMoviePlayerController (new NSUrl ("file.m4v"));
_moviePlayer.View.Frame = _someView.Frame;
_someView.AddSubview(_moviePlayer.View);
window.AddSubview(_someView);
_moviePlayer.Play ();
window.MakeKeyAndVisible ();
return true;
}
I added a simple example project here: https://docs.google.com/leaf?id=0B4a6jzbuiwbeOWQ5Y2JhZmQtMTNiYi00NWFiLTk3YmMtMTU1MjM2MjQxNTY4&hl=en_US
Upvotes: 5
Reputation: 1236
Tried this?
using MonoTouch.MediaPlayer;
var moviePlayer = new MPMoviePlayerController (new NSUrl ("file.m4v"));
moviePlayer.Play ();
I got it from here - http://wiki.monotouch.net/HowTo/Video/HowTo%3A_Playback_a_Video. - and there is reference to a MediaPlayer sample.
Upvotes: 2