/// <summary>
        /// Event handler when the user clicks the pick a video button
        /// </summary>
        /// <param name='sender'>
        /// Sender
        /// </param>
        partial void pickVideoBtnClicked(MonoTouch.Foundation.NSObject sender)
        {
            Console.WriteLine("pickVideoBtnClicked");

            picker = new MediaPicker();

            // Check that videos are supported on this device
            if (!picker.VideosSupported)
            {
                ShowUnsupported();
                return;
            }

            //
            // Call PickideoAsync, which returns a Task<MediaFile>
            picker.PickVideoAsync()
            .ContinueWith(t =>              // Continue when the user has picked a video
            {
                if (t.IsCanceled)           // The user canceled
                {
                    return;
                }

                // Play the video the user picked
                InvokeOnMainThread(delegate {
                    moviePlayer = new MPMoviePlayerViewController(NSUrl.FromFilename(t.Result.Path));
                    moviePlayer.MoviePlayer.UseApplicationAudioSession = true;
                    this.PresentMoviePlayerViewController(moviePlayer);
                });
            });
        }
Esempio n. 2
0
        public static void PlayVideo(string path, bool local)
        {
            NSUrl url = null;

            if (local)
            {
                url = NSUrl.FromFilename(path);
            }
            else
            {
                url = NSUrl.FromString(path);
            }

            MPMoviePlayerViewController movieController = new MPMoviePlayerViewController(url);
            UIViewController            controller      = AppMain.Current.Services.GetService(typeof(UIViewController)) as UIViewController;

            movieController.MoviePlayer.SetFullscreen(true, false);
            controller.PresentMoviePlayerViewController(movieController);
            movieController.MoviePlayer.Play();

            NSNotificationCenter.DefaultCenter.AddObserver(new NSString("MPMoviePlayerDidExitFullscreenNotification"), (not) =>
            {
                controller.DismissMoviePlayerViewController();
            });
        }
        /// <summary>
        /// Event handler when the user clicks the Take a Video button
        /// </summary>
        /// <param name='sender'>
        /// Sender
        /// </param>
        partial void takeVideoBtnClicked(MonoTouch.Foundation.NSObject sender)
        {
            Console.WriteLine("takeVideoBtnClicked");

            picker = new MediaPicker();

            // Check if a camera is available and videos are supported on this device
            if (!picker.IsCameraAvailable || !picker.VideosSupported)
            {
                ShowUnsupported();
                return;
            }

            // Call TakeVideoAsync, which returns a Task<MediaFile>.
            picker.TakeVideoAsync(new StoreVideoOptions
            {
                Quality       = VideoQuality.Medium,
                DesiredLength = new TimeSpan(0, 0, 30)
            })
            .ContinueWith(t =>              // Continue when the user has finished recording
            {
                if (t.IsCanceled)           // The user canceled
                {
                    return;
                }

                // Play the video the user recorded
                InvokeOnMainThread(delegate {
                    moviePlayer = new MPMoviePlayerViewController(NSUrl.FromFilename(t.Result.Path));
                    moviePlayer.MoviePlayer.UseApplicationAudioSession = true;
                    this.PresentMoviePlayerViewController(moviePlayer);
                });
            });
        }
Esempio n. 4
0
        /// <summary>
        /// Plays the streaming fullscreen movie.
        /// </summary>
        /// <param name="url">URL.</param>
        /// <param name="autoPlay">If set to <c>true</c> auto play.</param>
        /// <param name="style">Style.</param>
        public static void PlayStreamingFullscreenMovie(string url,
                                                        bool autoPlay             = true,
                                                        MPMovieControlStyle style = MPMovieControlStyle.Fullscreen)
        {
            contentURL = new NSURL(url);

            if (_playerVC == null)
            {
                _playerVC = new MPMoviePlayerViewController();

                _playerVC.moviePlayer.movieSourceType = MPMovieSourceType.Streaming;
                _playerVC.moviePlayer.contentURL      = contentURL;
                //		_playerVC.moviePlayer.SetFullscreen(true, false);
                _playerVC.moviePlayer.shouldAutoplay = autoPlay;


                _playerVC.moviePlayer.controlStyle = style;


                _playerVC.moviePlayer.LoadStateDidChange += _defaultMoviePlayerNotificationHandler;
                _playerVC.moviePlayer.DidExitFullscreen  += _defaultMoviePlayerExitFullscreen;
                _playerVC.moviePlayer.PlaybackDidFinish  += _defaultMoviePlayerFinishHandler;


                _playerVC.moviePlayer.PrepareToPlay();
            }
            else
            {
                _playerVC.moviePlayer.contentURL = contentURL;
                _playerVC.moviePlayer.PrepareToPlay();
            }

//			UIApplication.deviceRootViewController.AddChildViewController(_playerVC);
            UIApplication.deviceRootViewController.PresentViewController(_playerVC, false, null);
        }
Esempio n. 5
0
        /// <summary>
        /// Plays the streaming fullscreen movie.
        /// </summary>
        /// <param name="url">URL.</param>
        /// <param name="autoPlay">If set to <c>true</c> auto play.</param>
        /// <param name="style">Style.</param>
        public static void PlayStreamingFullscreenMovie(string url,
		                                                bool autoPlay = true, 
		                                                MPMovieControlStyle style=MPMovieControlStyle.Fullscreen)
        {
            contentURL = new NSURL(url);

            if (_playerVC == null) {
                _playerVC = new MPMoviePlayerViewController();

                _playerVC.moviePlayer.movieSourceType = MPMovieSourceType.Streaming;
                _playerVC.moviePlayer.contentURL = contentURL;
            //		_playerVC.moviePlayer.SetFullscreen(true, false);
                _playerVC.moviePlayer.shouldAutoplay = autoPlay;

                _playerVC.moviePlayer.controlStyle = style;

                _playerVC.moviePlayer.LoadStateDidChange += _defaultMoviePlayerNotificationHandler;
                _playerVC.moviePlayer.DidExitFullscreen += _defaultMoviePlayerExitFullscreen;
                _playerVC.moviePlayer.PlaybackDidFinish += _defaultMoviePlayerFinishHandler;

                _playerVC.moviePlayer.PrepareToPlay();

            } else {
                _playerVC.moviePlayer.contentURL = contentURL;
                _playerVC.moviePlayer.PrepareToPlay();
            }

            //			UIApplication.deviceRootViewController.AddChildViewController(_playerVC);
            UIApplication.deviceRootViewController.PresentViewController(_playerVC, false, null);
        }
Esempio n. 6
0
        public static void Play(string url)
        {
            bool autoplay   = true;
            var  parameters = HttpUtility.ParseQueryString(url.Substring(url.IndexOf('?')));

            if (parameters != null)
            {
                parameters.TryGetValue("source", out url);

                string play = null;
                parameters.TryGetValue("autoplay", out play);
                if (play != null)
                {
                    bool.TryParse(play, out autoplay);
                }
            }

            if (url == null)
            {
                throw new ArgumentNullException("source", "Video playback requires a source parameter to be specified");
            }

            var controller = new MPMoviePlayerViewController(File.Exists(url) ? NSUrl.FromFilename(url) : NSUrl.FromString(url));

            controller.MoviePlayer.ControlStyle   = MPMovieControlStyle.Fullscreen;
            controller.MoviePlayer.Fullscreen     = true;
            controller.MoviePlayer.ShouldAutoplay = autoplay;

            TouchFactory.Instance.TopViewController.PresentMoviePlayerViewController(controller);
        }
        protected override void Dispose(bool disposing)
        {
            Logger.Log("UIChaptersEnabledVideoView.Dispose: disposing = " + disposing);

            if (disposing)
            {
                willEnterForegroundNotification?.Dispose();
                willEnterForegroundNotification = null;

                didEnterBackgroundNotification?.Dispose();
                didEnterBackgroundNotification = null;

                playbackDidFinishNotification?.Dispose();
                playbackDidFinishNotification = null;

                playbackIsPreparedToPlayNotification?.Dispose();
                playbackIsPreparedToPlayNotification = null;

                playbackStateDidChangeNotification?.Dispose();
                playbackStateDidChangeNotification = null;

                adSkipTimer?.Dispose();
                adSkipTimer = null;

                if (moviePlayer != null)
                {
                    moviePlayer.MoviePlayer?.Dispose();
                    moviePlayer.Dispose();
                    moviePlayer = null;
                }
            }

            base.Dispose(disposing);
        }
        private void ShowVideo(MediaFile media)
        {
            dialogController.Media = media;

            moviePlayerView = new MPMoviePlayerViewController(NSUrl.FromFilename(media.Path));
            viewController.PresentMoviePlayerViewController(moviePlayerView);
        }
Esempio n. 9
0
        private void OnRequestMovieViewer(BaseContentCardViewModel viewModel)
        {
            var url = NSUrl.FromString(viewModel.MovieUrl);

            _movieController = new MPMoviePlayerViewController(url);

            PresentMoviePlayerViewController(_movieController);
        }
Esempio n. 10
0
 private void PlatformDispose(bool disposing)
 {
     if (MovieView == null)
         return;
     
     MovieView.Dispose();
     MovieView = null;
 }
Esempio n. 11
0
 public void Dispose()
 {
     if (_view != null)
     {
         _view.Dispose();
         _view = null;
     }
 }
Esempio n. 12
0
        /*
        // NOTE: https://developer.apple.com/library/ios/documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/Reference/Reference.html
        // It looks like BackgroundColor doesn't even exist anymore
        // in recent versions of iOS... Why still have this?
        public Color BackgroundColor
        {
            get
            {
                var col = MovieView.MoviePlayer.BackgroundColor;
                return new Color(col.X, col.Y, col.Z, col.W);
            }

            set
            {
                var col = value.ToVector4();
                return MovieView.MoviePlayer.BackgroundColor = MonoTouch.UIKit.UIColor(col.X, col.Y, col.Z, col.W);
            }
        }
        */

        private void PlatformInitialize()
        {
            var url = NSUrl.FromFilename(Path.GetFullPath(FileName));

            MovieView = new MPMoviePlayerViewController(url);
            MovieView.MoviePlayer.ScalingMode = MPMovieScalingMode.AspectFill;
            MovieView.MoviePlayer.ControlStyle = MPMovieControlStyle.None;
            MovieView.MoviePlayer.PrepareToPlay();
        }
Esempio n. 13
0
        /*
         * // NOTE: https://developer.apple.com/library/ios/documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/Reference/Reference.html
         * // It looks like BackgroundColor doesn't even exist anymore
         * // in recent versions of iOS... Why still have this?
         * public Color BackgroundColor
         * {
         *  get
         *  {
         *      var col = MovieView.MoviePlayer.BackgroundColor;
         *      return new Color(col.X, col.Y, col.Z, col.W);
         *  }
         *
         *  set
         *  {
         *      var col = value.ToVector4();
         *      return MovieView.MoviePlayer.BackgroundColor = MonoTouch.UIKit.UIColor(col.X, col.Y, col.Z, col.W);
         *  }
         * }
         */

        private void PlatformInitialize()
        {
            var url = NSUrl.FromFilename(Path.GetFullPath(FileName));

            MovieView = new MPMoviePlayerViewController(url);
            MovieView.MoviePlayer.ScalingMode  = MPMovieScalingMode.AspectFill;
            MovieView.MoviePlayer.ControlStyle = MPMovieControlStyle.None;
            MovieView.MoviePlayer.PrepareToPlay();
        }
Esempio n. 14
0
        private void PlatformDispose(bool disposing)
        {
            if (MovieView == null)
            {
                return;
            }

            MovieView.Dispose();
            MovieView = null;
        }
 /// <inheritdoc/>
 public override void PresentMoviePlayerViewController(MPMoviePlayerViewController moviePlayerViewController)
 {
     if (TopMostPresentedController == null)
     {
         base.PresentMoviePlayerViewController(moviePlayerViewController);
     }
     else
     {
         TopMostPresentedController.PresentMoviePlayerViewController(moviePlayerViewController);
     }
 }
Esempio n. 16
0
        internal void Prepare()
        {
            _view = new MPMoviePlayerViewController(new NSUrl(FileName));
            _view.MoviePlayer.ScalingMode      = MPMovieScalingMode.AspectFill;
            _view.MoviePlayer.MovieControlMode = MPMovieControlMode.Hidden;
            _view.MoviePlayer.PrepareToPlay();

            Vector4 color = BackgroundColor.ToEAGLColor();

            _view.MoviePlayer.BackgroundColor = new MonoTouch.UIKit.UIColor(color.X, color.Y, color.Z, color.W);
        }
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     if (disposing)
     {
         NSNotificationCenter.DefaultCenter.RemoveObservers(_observers);
         if (_player != null)
         {
             _player.Dispose();
             _player = null;
         }
     }
 }
Esempio n. 18
0
        internal void Prepare()
        {
            var url = NSUrl.FromFilename(Path.GetFullPath(FileName));

            _view = new MPMoviePlayerViewController(url);
            _view.MoviePlayer.ScalingMode      = MPMovieScalingMode.AspectFill;
            _view.MoviePlayer.MovieControlMode = MPMovieControlMode.Hidden;
            _view.MoviePlayer.PrepareToPlay();

            Vector4 color = BackgroundColor.ToVector4();

            _view.MoviePlayer.BackgroundColor = new MonoTouch.UIKit.UIColor(color.X, color.Y, color.Z, color.W);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <VideoPlayer> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                if (base.Control == null)
                {
                    _player = new MPMoviePlayerViewController();
                    _player.MoviePlayer.ShouldAutoplay = false;
                    _player.MoviePlayer.ScalingMode    = MPMovieScalingMode.AspectFit;
                    _player.MoviePlayer.PrepareToPlay();

                    //_player.View.AddGestureRecognizer(new UITapGestureRecognizer(() => Element.FirePlayerTapped(this)));
                    base.SetNativeControl(_player.View);

                    //Add to root view controller as child
                    var rootVC = UIApplication.SharedApplication?.KeyWindow?.RootViewController;
                    if (rootVC == null)
                    {
                        return;
                    }
                    rootVC.AddChildViewController(_player);
                    _player.DidMoveToParentViewController(rootVC);

                    //Subscribe to necessary notifications
                    var center = NSNotificationCenter.DefaultCenter;
                    _observers.Add(center.AddObserver(MPMoviePlayerController.PlaybackStateDidChangeNotification, playbackStateChanged));
                    _observers.Add(center.AddObserver(MPMoviePlayerController.PlaybackDidFinishNotification, playbackFinished));
                }
                e.NewElement.TogglePlay           = togglePlay;
                e.NewElement.Play                 = () => _player.MoviePlayer.Play();
                e.NewElement.Stop                 = () => _player.MoviePlayer.Stop();
                e.NewElement.HideFullScreenButton = hideFullScreenButton;
            }
            if (Element == null)
            {
                return;
            }

            updateVideoPath();
            updateControls();
        }
            public override void RowSelected(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
            {
                // Navigation logic may go here -- for example, create and push another view controller.
                //var programDetailViewController = new ProgramDetailViewController ();
                //programDetailViewController.SelectedProgram = programs[indexPath.Row];
                //controller.NavigationController.PushViewController(programDetailViewController, true);
                var SelectedProgram = downloads[indexPath.Row];

                Console.WriteLine("playing " + Path.Combine(AppDelegate.DocumentsFolder, SelectedProgram.MoviePath));

                if (moviePlayer != null)
                {
                    moviePlayer.Dispose();
                    moviePlayer = null;
                }

                moviePlayer = new MPMoviePlayerViewController(new NSUrl(Path.Combine(AppDelegate.DocumentsFolder, SelectedProgram.MoviePath), false));

                controller.PresentMoviePlayerViewController(moviePlayer);
            }
Esempio n. 21
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            
            // Perform any additional setup after loading the view, typically from a nib.
            
            AddSateliteMenu();
            AddMissions();
            
            liveStreamsButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                var videoPlayer = new MPMoviePlayerViewController();
                videoPlayer.MoviePlayer.ContentUrl = NSUrl.FromString("http://media.infozen.cshls.lldns.net/infozen/media/media.m3u8");
                PresentMoviePlayerViewController(videoPlayer);
            };
            
            var set = this.CreateBindingSet<EarthView, EarthViewModel>();
            set.Bind(aboutButton).To("ShowAboutViewCommand"); 
            set.Bind(newsButton).To("ShowNewsOverviewViewCommand"); 
            set.Apply();

        }
Esempio n. 22
0
 public void ShowFullScreenVideo(string url)
 {
     if (_moviePlayer != null)
     {
         _moviePlayer.Dispose();
         _moviePlayer = null;
     }
     if (_moviePlayerVC != null)
     {
         _moviePlayerVC.Dispose();
         _moviePlayerVC = null;
     }
     if (App.Inst.IsIPad)
     {
         _moviePlayerVC = new MPMoviePlayerViewController(new NSUrl(url));
         MVC.PresentMoviePlayerViewController(_moviePlayerVC);
     }
     else
     {
         _moviePlayer = new MPMoviePlayerController(new NSUrl(url));
         _moviePlayer.Play();
     }
 }
Esempio n. 23
0
        internal void Prepare()
        {
            _view = new MPMoviePlayerViewController(new NSUrl(FileName));
            _view.MoviePlayer.ScalingMode = MPMovieScalingMode.AspectFill;
            _view.MoviePlayer.MovieControlMode = MPMovieControlMode.Hidden;
            _view.MoviePlayer.PrepareToPlay();

            Vector4 color = BackgroundColor.ToEAGLColor();
            _view.MoviePlayer.BackgroundColor = new MonoTouch.UIKit.UIColor(color.X,color.Y,color.Z,color.W);
        }
            public override void RowSelected(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
            {
                // Navigation logic may go here -- for example, create and push another view controller.
                //var programDetailViewController = new ProgramDetailViewController ();
                //programDetailViewController.SelectedProgram = programs[indexPath.Row];
                //controller.NavigationController.PushViewController(programDetailViewController, true);
                var SelectedProgram = downloads[indexPath.Row];
                Console.WriteLine("playing " + Path.Combine(AppDelegate.DocumentsFolder, SelectedProgram.MoviePath));

                if (moviePlayer != null)
                {
                    moviePlayer.Dispose();
                    moviePlayer = null;
                }

                moviePlayer = new MPMoviePlayerViewController(new NSUrl(Path.Combine(AppDelegate.DocumentsFolder, SelectedProgram.MoviePath), false));

                controller.PresentMoviePlayerViewController(moviePlayer);
            }
        public UIChaptersEnabledVideoView(LibraryItem video, CGRect frame, ChaptersEnabledVideoView videoView)
        {
            this.videoView = videoView;
            this.video     = video;

            AutoresizingMask = UIViewAutoresizing.All;
            ContentMode      = UIViewContentMode.ScaleAspectFill;

            if (!string.IsNullOrEmpty(video.LocalFilePath))
            {
                Logger.Log("UIChaptersEnabledVideoView.ctor: video.LocalFilePath = '" + video.LocalFilePath + "'");

                MPNowPlayingInfoCenter.DefaultCenter.NowPlaying = new MPNowPlayingInfo()
                {
                    Title = video.Title
                };

                var linkPath = LocalLibraryService.Instance.GetLinkForMediaItem(video);
                moviePlayer = new MPMoviePlayerViewController(NSUrl.FromFilename(string.IsNullOrEmpty(linkPath) ? video.LocalFilePath : linkPath))
                {
                    View =
                    {
                        ContentMode      = UIViewContentMode.ScaleAspectFill,
                        AutoresizingMask = UIViewAutoresizing.All
                    },

                    MoviePlayer =
                    {
                        RepeatMode    = MPMovieRepeatMode.None,
                        ControlStyle  = MPMovieControlStyle.Fullscreen,
                        ScalingMode   = MPMovieScalingMode.AspectFit,
                        AllowsAirPlay = true
                    }
                };

                Frame = moviePlayer.View.Frame = frame;
                Add(moviePlayer.View);

                playbackDidFinishNotification = MPMoviePlayerController.Notifications.ObservePlaybackDidFinish(playBackFinishedHandler);

                NSNotificationCenter.DefaultCenter.RemoveObserver(moviePlayer, UIApplication.DidEnterBackgroundNotification, null);
                willEnterForegroundNotification = UIApplication.Notifications.ObserveWillEnterForeground(willEnterForegroundHandler);
                didEnterBackgroundNotification  = UIApplication.Notifications.ObserveDidEnterBackground(didEnterBackgroundHandler);

                var bookmarkTime = (int)video.BookmarkTime;
                if ((bookmarkTime == -2) || (bookmarkTime == 0))
                {
                    bookmarkTime = -1;
                }

                if (videoView.SkipAdvertisements)
                {
                    bool hasBookmarkTimeValue = false;

                    for (int i = 0; i < video.Chapters.Count; i++)
                    {
                        Chapter chapter = video.Chapters[i];
                        chapter.IsSkipped = false;

                        if (!hasBookmarkTimeValue && (chapter.Type != ChapterType.Advertisement))
                        {
                            int chapterStartTime = (int)chapter.StartTime;
                            if (chapterStartTime != 0)
                            {
                                bookmarkTime = chapterStartTime;
                            }

                            hasBookmarkTimeValue = true;
                        }
                    }
                }

                if ((videoView.SkipAdvertisements) || ((bookmarkTime > 0) && UIDevice.CurrentDevice.CheckSystemVersion(8, 4)))
                {
                    playbackStateDidChangeNotification = MPMoviePlayerController.Notifications.ObservePlaybackStateDidChange(playbackStateDidChange);
                }

                if (bookmarkTime > 0)
                {
                    if (UIDevice.CurrentDevice.CheckSystemVersion(8, 4))
                    {
                        initialPlaybackTime = TimeSpan.FromSeconds(bookmarkTime);
                    }
                    else
                    {
                        moviePlayer.MoviePlayer.InitialPlaybackTime = bookmarkTime;
                    }
                }

                if (moviePlayer.MoviePlayer.IsPreparedToPlay)
                {
                    moviePlayer.MoviePlayer.Play();
                }
                else
                {
                    playbackIsPreparedToPlayNotification = MPMoviePlayerController.Notifications.ObserveMediaPlaybackIsPreparedToPlayDidChange(playBackIsPreparedToPlayHandler);
                    moviePlayer.MoviePlayer.PrepareToPlay();
                }
            }
            else
            {
                exitPlayback(PlaybackExitReason.Error);
            }
        }
Esempio n. 26
0
		internal void Prepare()
		{
            var url = NSUrl.FromFilename(Path.GetFullPath(FileName));

			_view = new MPMoviePlayerViewController(url);
			_view.MoviePlayer.ScalingMode = MPMovieScalingMode.AspectFill;
			_view.MoviePlayer.MovieControlMode = MPMovieControlMode.Hidden;
			_view.MoviePlayer.PrepareToPlay();
			
			Vector4 color = BackgroundColor.ToVector4();
			_view.MoviePlayer.BackgroundColor = new MonoTouch.UIKit.UIColor(color.X,color.Y,color.Z,color.W);
		}
Esempio n. 27
0
 public void Dispose()
 {
     if (_view != null)
     {
         _view.Dispose();
         _view = null;
     }
 }
Esempio n. 28
0
		private void ShowVideo (MediaFile media)
		{
			dialogController.Media = media;

			moviePlayerView = new MPMoviePlayerViewController (NSUrl.FromFilename (media.Path));
			viewController.PresentMoviePlayerViewController (moviePlayerView);
		}
		/// <summary>
		/// Event handler when the user clicks the Take a Video button
		/// </summary>
		/// <param name='sender'>
		/// Sender
		/// </param>
		partial void takeVideoBtnClicked (MonoTouch.Foundation.NSObject sender)
		{
			Console.WriteLine("takeVideoBtnClicked");
			
			picker = new MediaPicker ();
			
			// Check if a camera is available and videos are supported on this device
			if (!picker.IsCameraAvailable || !picker.VideosSupported)
			{
				ShowUnsupported();
				return;
			}
			
			// Call TakeVideoAsync, which returns a Task<MediaFile>.
			picker.TakeVideoAsync (new StoreVideoOptions
			{
				Quality = VideoQuality.Medium,
				DesiredLength = new TimeSpan(0, 0, 30)
			})
			.ContinueWith (t => // Continue when the user has finished recording
			{
				if (t.IsCanceled) // The user canceled
					return;
					
				// Play the video the user recorded
				InvokeOnMainThread( delegate {
					moviePlayer = new MPMoviePlayerViewController (NSUrl.FromFilename(t.Result.Path));
					moviePlayer.MoviePlayer.UseApplicationAudioSession = true;
		    		this.PresentMoviePlayerViewController(moviePlayer);
				});
			});
		}
		/// <summary>
		/// Event handler when the user clicks the pick a video button 
		/// </summary>
		/// <param name='sender'>
		/// Sender
		/// </param>
		partial void pickVideoBtnClicked (MonoTouch.Foundation.NSObject sender)
		{
			Console.WriteLine("pickVideoBtnClicked");
			
			picker = new MediaPicker ();
			
			// Check that videos are supported on this device
			if (!picker.VideosSupported)
			{
				ShowUnsupported();
				return;
			}
			
			//
			// Call PickideoAsync, which returns a Task<MediaFile>
			picker.PickVideoAsync ()
			.ContinueWith (t => // Continue when the user has picked a video
			{
				if (t.IsCanceled) // The user canceled
					return;
					
				// Play the video the user picked
				InvokeOnMainThread( delegate {
					moviePlayer = new MPMoviePlayerViewController (NSUrl.FromFilename(t.Result.Path));
					moviePlayer.MoviePlayer.UseApplicationAudioSession = true;
		    		this.PresentMoviePlayerViewController(moviePlayer);
				});
			});
		}
Esempio n. 31
0
		private void OnRequestMovieViewer (BaseContentCardViewModel viewModel)
		{
			var url = NSUrl.FromString(viewModel.MovieUrl);
			_movieController = new MPMoviePlayerViewController(url);
		
			PresentMoviePlayerViewController (_movieController);
		}
Esempio n. 32
0
		public void BindVideos (List<Model.Video> videos)
		{
			if (videos == null)
				return;
			
			RootElement root = new RootElement (Title);
			
			foreach (var video in videos) {
				var element = new VideoElement (video);
				if (!video.IsYoutube) {
					element.VideoSelected += delegate(object sender, EventArgs<Model.Video> e) {
						var mv = new MPMoviePlayerViewController (new NSUrl (e.Value.Url));
						mv.Title = e.Value.Title;
						PresentMoviePlayerViewController (mv);
					};
				}
				root.Add (new Section { element });
			}
			Root = root;
			
		}
Esempio n. 33
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            //Show an edit button

            //NavigationItem.RightBarButtonItem = EditButtonItem;

            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
            SelectedProgram.PopulateExtendedFields();



            this.Title              = SelectedProgram.Program.Name;
            this.TitleLabel.Text    = SelectedProgram.Program.Name;
            this.SubtitleLabel.Text = SelectedProgram.Program.Description;
            SubtitleLabel.Font      = UIFont.SystemFontOfSize(UIFont.SmallSystemFontSize);
            this.ImageView.Image    = SelectedProgram.GetFullsizeImage(ImageView.Bounds);

            UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;

            if (SelectedProgram.DownloadedFileExists)
            {
                this.DownloadButton.SetTitle("Play", UIControlState.Normal);
            }

            this.WatchButton.TouchUpInside += delegate {
                // This is for when the user wants to stream the video
                string url = SelectedProgram.StreamingUrl;
                if (string.IsNullOrEmpty(url))
                {
                    using (UIAlertView alertView = new UIAlertView("Sorry.", "Sorry, this program is not available for streaming.", null, "OK"))
                    {
                        alertView.Show();
                        this.WatchButton.SetTitle("Not available", UIControlState.Normal);
                    }
                }
                else
                {
                    moviePlayer = new MPMoviePlayerViewController(new NSUrl(SelectedProgram.StreamingUrl));
                    PresentMoviePlayerViewController(moviePlayer);
                }
            };

            this.DownloadButton.TouchUpInside += delegate {
                if (SelectedProgram.DownloadedFileExists)
                {
                    // if we have the file, we can play it! yay!
                    Console.WriteLine("playing");
                    moviePlayer = new MPMoviePlayerViewController(new NSUrl(SelectedProgram.OutputFilename, false));
                    PresentMoviePlayerViewController(moviePlayer);
                }
                else
                {
                    //If you happen to be out of the UK, but want to see how the queueing works, you may want to remove this
                    // bit, as it checks if you can download and will not queue if it can't.
                    // you still can't download, obviously, but atleast you can see the workflow.

                    if (SelectedProgram.PrepareForQueue())
                    {
                        LocalProgram localQueueProgram = LocalProgramHelper.LocalProgramFromRemoteProgram(SelectedProgram.Program);

                        localQueueProgram.State = "Q";
                        AppDelegate.SessionDatabase.AddLocalProgram(localQueueProgram);

                        this.DownloadButton.SetTitle("Queued", UIControlState.Normal);
                    }
                    else
                    {
                        // could be that you are outside of the UK, on 3G, or just that the show isn't ready yet.
                        using (UIAlertView alertView = new UIAlertView("Sorry.", "Sorry, this program is not available for download.", null, "OK"))
                        {
                            alertView.Show();
                            this.DownloadButton.SetTitle("Not available", UIControlState.Normal);
                        }
                    }
                    this.DownloadButton.Enabled = false;
                }
            };
        }