Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void PlayVideo(string path)
- {
- using (var pool = new NSAutoreleasePool())
- {
- try
- {
- pool.InvokeOnMainThread(delegate {
- if (playing)
- {
- StopVideo();
- }
- playerView = new MPMoviePlayerViewController();
- playerView.MoviePlayer.ScalingMode = MPMovieScalingMode.AspectFit;
- playerView.MoviePlayer.MovieControlMode = MPMovieControlMode.Default;
- playerView.MoviePlayer.Fullscreen = true;
- stopObserver = NSNotificationCenter.DefaultCenter.AddObserver(
- MPMoviePlayerController.PlaybackDidFinishNotification,
- (NSNotification) => OnVideoStop(null), playerView.MoviePlayer);
- window.AddSubview(playerView.View);
- playerView.MoviePlayer.ContentUrl = new NSUrl(path);
- playerView.MoviePlayer.Play();
- if (VideoStarted != null)
- {
- VideoStarted(null, EventArgs.Empty);
- }
- playing = true;
- });
- }
- catch (Exception e)
- {
- global::System.Diagnostics.Debug.WriteLine("Exception calling PlayVideo: " + e.ToString());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment