r2d2rigo

Untitled

Mar 2nd, 2012
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1.         public void PlayVideo(string path)
  2.         {
  3.             using (var pool = new NSAutoreleasePool())
  4.             {
  5.                 try
  6.                 {
  7.                     pool.InvokeOnMainThread(delegate {
  8.                         if (playing)
  9.                         {
  10.                             StopVideo();
  11.                         }
  12.                         playerView = new MPMoviePlayerViewController();
  13.                         playerView.MoviePlayer.ScalingMode = MPMovieScalingMode.AspectFit;
  14.                         playerView.MoviePlayer.MovieControlMode = MPMovieControlMode.Default;
  15.                         playerView.MoviePlayer.Fullscreen = true;
  16.  
  17.                         stopObserver = NSNotificationCenter.DefaultCenter.AddObserver(
  18.                             MPMoviePlayerController.PlaybackDidFinishNotification,
  19.                             (NSNotification) => OnVideoStop(null), playerView.MoviePlayer);
  20.                        
  21.                         window.AddSubview(playerView.View);
  22.                         playerView.MoviePlayer.ContentUrl = new NSUrl(path);
  23.                         playerView.MoviePlayer.Play();
  24.                        
  25.                         if (VideoStarted != null)
  26.                         {
  27.                             VideoStarted(null, EventArgs.Empty);
  28.                         }
  29.                         playing = true;
  30.                     });
  31.                 }
  32.                 catch (Exception e)
  33.                 {
  34.                     global::System.Diagnostics.Debug.WriteLine("Exception calling PlayVideo: " + e.ToString());
  35.                 }
  36.             }
  37.         }
Advertisement
Add Comment
Please, Sign In to add comment