public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //Button Events
            playMovieButton.TouchUpInside += delegate {
                try{
                    //Set already instantiated MPMoviePlayerController to playback from Movies/file.m4v
                    mp = new MPMoviePlayerController(NSUrl.FromFilename("Movies/file.m4v"));

                    //enable AirPlay
                    mp.AllowsAirPlay = true;

                    //Add the MPMoviePlayerController View
                    this.View.AddSubview(mp.View);

                    //set the view to be full screen and show animated
                    mp.SetFullscreen(true, true);

                    //Disable the pinch-to-zoom gesture
                    mp.ControlStyle = MPMovieControlStyle.Fullscreen;

                    //MPMoviePlayer must be set to PrepareToPlay before playback
                    mp.PrepareToPlay();

                    //Play Movie
                    mp.Play();
                } catch {
                    Console.WriteLine("There was a problem playing back Video");
                }
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            //this.ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation.LandscapeRight);
            UIWindow window = UIApplication.SharedApplication.KeyWindow;
            var rootController = window.RootViewController.ChildViewControllers [0].ChildViewControllers [1];
            rootController.TabBarController.TabBar.Hidden = true;

            this.NavigationController.NavigationBarHidden = true;

            moviePlayer = new MPMoviePlayerController (new NSUrl (MediaFile));
            MPMoviePlayerController.Notifications.ObserveLoadStateDidChange(OnLoadStateChanged);
            MPMoviePlayerController.Notifications.ObservePlaybackDidFinish(OnPlaybackComplete);

            //moviePlayer.View.Frame = new CGRect((float)((this.View.Bounds.Width - 600) / 2), (float)((this.View.Bounds.Height - 450) / 2), 600, 400);

            View.AddSubview (moviePlayer.View);

            moviePlayer.PrepareToPlay();
            moviePlayer.ShouldAutoplay = true;
            moviePlayer.ControlStyle = MPMovieControlStyle.Fullscreen;
            moviePlayer.SetFullscreen (true, true);
            moviePlayer.Play();
        }
Ejemplo n.º 3
0
        public static void ShowVideoUrlMp4(this UIView view, string pathVideo)
        {
            var moviePlayer = new MPMoviePlayerController
            {
                ContentUrl     = new NSUrl(pathVideo),
                ShouldAutoplay = false,
                ControlStyle   = MPMovieControlStyle.Embedded
            };


            moviePlayer.View.Frame = view.Frame;
            moviePlayer.PrepareToPlay();

            moviePlayer.Play();
            moviePlayer.SetFullscreen(true, true);


            MPMoviePlayerController.Notifications.ObserveDidExitFullscreen((sender, e) =>
            {
                moviePlayer.Stop();
                moviePlayer.View.RemoveFromSuperview();
                moviePlayer.Dispose();
                moviePlayer = null;
                GC.Collect();
            });

            view.AddSubview(moviePlayer.View);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            RefreshControl.ValueChanged += (sender, e) => Task.Run(async() => await Refresh());
            CollectionView.AddSubview(RefreshControl);
            var deletate = new CustomFlowLayoutDelegate();

            deletate.ItemClick += async(sender, e) =>
            {
                var item = await Detail.GetVideo(ID, List[e.Index].Set, LanguageHelper.PrefLang);

                var picker = new UIPickerView();
                var model  = new QualityPickerViewModel(item);
                model.ItemClick += (s2, e2) =>
                {
                    View.WillRemoveSubview(picker);
                    if (moviePlayer == null)
                    {
                        moviePlayer = new MPMoviePlayerController();
                        View.AddSubview(moviePlayer.View);
                        moviePlayer.ShouldAutoplay = true;
                    }
                    moviePlayer.ContentUrl = NSUrl.FromString(item.ToDictionary().Values.ToArray()[e2.Index]);
                    moviePlayer.SetFullscreen(true, false);
                    moviePlayer.PrepareToPlay();
                    moviePlayer.Play();
                };
                View.AddSubview(picker);
                picker.Hidden = false;
            };
            CollectionView.Delegate = deletate;
            CollectionView.RegisterClassForCell(typeof(DetailCell), _detailCellId);
            CollectionView.ContentInset = new UIEdgeInsets(4, 4, 4, 4);
            Task.Run(async() => await Refresh());
        }
Ejemplo n.º 5
0
        protected override void OnElementChanged(ElementChangedEventArgs <VideoView> e)
        {
            if (e.NewElement != null)
            {
                if (string.IsNullOrEmpty(Element.Source))
                {
                    throw new ArgumentException("Source is required.");
                }

                if (base.Control == null)
                {
                    var view = new UIView();
                    SetNativeControl(view);

                    if (Element.ShowControl)
                    {
                        if (Element.IsFromUrl)
                        {
                            if (movieController == null)
                            {
                                var url = NSUrl.FromString(Element.Source);
                                movieController = new MPMoviePlayerController();
                                movieController.ShouldAutoplay = true;
                                movieController.Fullscreen     = true;
                                movieController.ControlStyle   = MPMovieControlStyle.Embedded;
                                movieController.PrepareToPlay();
                                movieController.SourceType = MPMovieSourceType.Streaming;
                                movieController.ContentUrl = url;
                                view.Add(movieController.View);

                                movieController.Play();
                                movieController.SetFullscreen(true, true);
                            }
                        }
                    }
                    else
                    {
                        if (playerItem == null)
                        {
                            asset      = AVAsset.FromUrl(NSUrl.FromFilename(Element.Source));
                            playerItem = new AVPlayerItem(asset);
                            //					AVPlayerItem.DidPlayToEndTimeNotification;

                            player = new AVPlayer(playerItem);
                            player.ActionAtItemEnd = AVPlayerActionAtItemEnd.None;
                            playerLayer            = AVPlayerLayer.FromPlayer(player);


                            view.Layer.AddSublayer(playerLayer);


                            SetRepeat();
                            SetPlaying();
                        }
                    }
                }
            }

            base.OnElementChanged(e);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Stops the movie player
        /// </summary>
        /// <param name="notification">Notification.</param>
        public void VideoFinished(NSNotification notification)
        {
            //firing twice???
            Debug.WriteLine("video finished or user hit done!");

            MoviePlayer.SetFullscreen(false, false);
            MoviePlayer.Stop();
        }
Ejemplo n.º 7
0
        public void PlayVideo(string videoName)
        {
            var moviePlayer = new MPMoviePlayerController(NSUrl.FromFilename(videoName));

            NavigationContext.View.AddSubview(moviePlayer.View);
            moviePlayer.SetFullscreen(true, true);
            moviePlayer.Play();
        }
Ejemplo n.º 8
0
 void playMedia()
 {
     moviePlayer = new MPMoviePlayerController(NSUrl.FromString(url));
     View.AddSubview(moviePlayer.View);
     moviePlayer.View.Frame = View.Frame;
     moviePlayer.SetFullscreen(true, true);
     moviePlayer.PrepareToPlay();
     moviePlayer.Play();
 }
		public void PlayVideo (string path)
		{
			MPMoviePlayerController moviePlayer; 
			moviePlayer = new MPMoviePlayerController (NSUrl.FromFilename (path));
			UIApplication.SharedApplication.KeyWindow.RootViewController.Add( moviePlayer.View );
			moviePlayer.ShouldAutoplay = true;
			moviePlayer.SetFullscreen (true,true);
			moviePlayer.Play ();
		}
Ejemplo n.º 10
0
        partial void UIButton3_TouchUpInside(UIButton sender)
        {
            //Video File
            string videoFile = "Video.mp4";
            MPMoviePlayerController player = new MPMoviePlayerController(NSUrl.FromFilename(videoFile));

            View.AddSubview(player.View);
            player.SetFullscreen(true, true);
            player.Play();
        }
Ejemplo n.º 11
0
 public override void ViewDidLoad()
 {
     base.ViewDidLoad ();
     moviePlayer = new MPMoviePlayerController (new NSUrl ("http://ia600507.us.archive.org/25/items/Cartoontheater1930sAnd1950s1/PigsInAPolka1943.mp4"));
     moviePlayer.View.Frame = new System.Drawing.RectangleF(0,0,View.Bounds.Width, 100);
     //this.AddChildViewController(moviePlayer);
     View.AddSubview (moviePlayer.View);
     moviePlayer.SetFullscreen (true, true);
     moviePlayer.Play ();
 }
Ejemplo n.º 12
0
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     moviePlayer            = new MPMoviePlayerController(new NSUrl("http://ia600507.us.archive.org/25/items/Cartoontheater1930sAnd1950s1/PigsInAPolka1943.mp4"));
     moviePlayer.View.Frame = new System.Drawing.RectangleF(0, 0, View.Bounds.Width, 100);
     //this.AddChildViewController(moviePlayer);
     View.AddSubview(moviePlayer.View);
     moviePlayer.SetFullscreen(true, true);
     moviePlayer.Play();
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            playMovie.TouchUpInside += delegate {
                moviePlayer = new MPMoviePlayerController (NSUrl.FromFilename ("sample.m4v"));

                View.AddSubview (moviePlayer.View);
                moviePlayer.SetFullscreen (true, true);
                moviePlayer.Play ();
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();


            playMovie.TouchUpInside += delegate {
                moviePlayer = new MPMoviePlayerController(NSUrl.FromFilename("sample.m4v"));

                View.AddSubview(moviePlayer.View);
                moviePlayer.SetFullscreen(true, true);
                moviePlayer.Play();
            };
        }
Ejemplo n.º 15
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title = "Video";

            btnPlay.TouchUpInside += (object sender, EventArgs e) => {
                moviePlayer = new MPMoviePlayerController(NSUrl.FromFilename("sample_iPod.m4v"));

                View.AddSubview(moviePlayer.View);
                moviePlayer.SetFullscreen(true, true);
                moviePlayer.Play();
            };
        }
Ejemplo n.º 16
0
        private void playVideo(string videoFile)
        {
            MPMoviePlayerController moviePlayer = new MPMoviePlayerController(NSUrl.FromFilename(videoFile));

            owner.View.AddSubview(moviePlayer.View);
            moviePlayer.SetFullscreen(true, true);
            moviePlayer.Play();
            NSNotificationCenter.DefaultCenter.AddObserver(
                MPMoviePlayerController.PlaybackDidFinishNotification,
                (notification) =>
            {
                moviePlayer.View.RemoveFromSuperview();
                moviePlayer.Dispose();
            });
        }
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);

            var page = e.NewElement as DownloadViewer;
            var fileItem = page.FileItem;

            UIWindow window = UIApplication.SharedApplication.KeyWindow;
            var rootController = window.RootViewController.ChildViewControllers [0].ChildViewControllers [3].TabBarController;
            rootController.TabBar.Hidden = true;

            //var url = new NSUrl.FromFilename (new Uri (fileItem.FilePath).ToString ());
            moviePlayer = new MPMoviePlayerController();
            var documents = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments);
            var directoryname = Path.Combine (documents, "Downloads");
            var path = Path.Combine (directoryname, fileItem.FilePath);

            moviePlayer.ContentUrl = NSUrl.FromFilename (path);

            screenWidth = (int)UIScreen.MainScreen.Bounds.Width;
            screenHeight = (int)UIScreen.MainScreen.Bounds.Height;

            //moviePlayer.View.Frame = new CGRect(0,(NativeView.Bounds.Height - 300)/2,NativeView.Bounds.Width,300);
            moviePlayer.View.Frame = new CGRect(0, 0, screenWidth, screenHeight);

            MPMoviePlayerController.Notifications.ObserveLoadStateDidChange(OnLoadStateChanged);
            MPMoviePlayerController.Notifications.ObservePlaybackDidFinish(OnPlaybackComplete);

            var overlayView = moviePlayer.View;
            View.AddSubview(overlayView);
            //View.AddSubview(moviePlayer.View);
            List<NSLayoutConstraint> constraints = new List<NSLayoutConstraint>();
            constraints.Add (NSLayoutConstraint.Create (View, NSLayoutAttribute.Top, NSLayoutRelation.Equal, overlayView, NSLayoutAttribute.Top, 1f, 0));
            constraints.Add (NSLayoutConstraint.Create (View, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, overlayView, NSLayoutAttribute.Bottom, 1f, -0));
            constraints.Add (NSLayoutConstraint.Create (View, NSLayoutAttribute.Left, NSLayoutRelation.Equal, overlayView, NSLayoutAttribute.Left, 1f, 0));
            constraints.Add (NSLayoutConstraint.Create (View, NSLayoutAttribute.Right, NSLayoutRelation.Equal, overlayView, NSLayoutAttribute.Right, 1f, -0));

            View.AddConstraints (constraints.ToArray ());

            moviePlayer.PrepareToPlay();
            moviePlayer.ShouldAutoplay = true;
            moviePlayer.SetFullscreen (true, true);
            moviePlayer.ControlStyle = MPMovieControlStyle.Fullscreen;
            moviePlayer.Play();
        }
        public UIVideoView(string uriSource, CGRect frame)
        {
            this.AutoresizingMask = UIViewAutoresizing.All;
            this.ContentMode      = UIViewContentMode.ScaleToFill;

            _moviePlayer = new MPMoviePlayerController(NSUrl.FromString(uriSource));
            _moviePlayer.View.ContentMode      = UIViewContentMode.ScaleToFill;
            _moviePlayer.View.AutoresizingMask = UIViewAutoresizing.All;
            _moviePlayer.RepeatMode            = MPMovieRepeatMode.One;
            _moviePlayer.ControlStyle          = MPMovieControlStyle.Default;
            _moviePlayer.ScalingMode           = MPMovieScalingMode.AspectFit;
            _moviePlayer.MovieControlMode      = MPMovieControlMode.Default;
            this.Frame = _moviePlayer.View.Frame = frame;
            Add(_moviePlayer.View);
            _moviePlayer.SetFullscreen(true, true);
            _moviePlayer.Play();
            _isPlaying = true;
        }
        void HandleMediaFileSelected(object sender, FileSelectedEventArgs args)
        {
            NavigationController.PopToViewController(this, true);

            try {
                var player = new MPMoviePlayerController(NSUrl.FromFilename(args.File))
                {
                    AllowsAirPlay = true
                };

                View.AddSubview(player.View);
                player.SetFullscreen(true, true);
                player.PrepareToPlay();
                player.Play();
            } catch (Exception ex) {
                string message = string.Format("Error during playback of {0}: {1}", Path.GetFileName(args.File), ErrorHandling.GetExceptionDetailedText(ex));
                LogMessage(message);
            }
        }
Ejemplo n.º 20
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            if (media.Type == "Image")
            {
                this.View.Add(this.autoResizingImage);
                this.View.BackgroundColor = UIColor.White;
                this.Title = "Image";
            }
            else
            {
                this.Title = "Video";
                try
                {
                    var nsurl = NSUrl.FromFilename((Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "/" + media.URL));
                    //Set already instantiated MPMoviePlayerController to playback from Movies/file.m4v
                    moviePlayer = new MPMoviePlayerController(nsurl);

                    //enable AirPlay
                    moviePlayer.AllowsAirPlay = true;

                    //Add the MPMoviePlayerController View
                    this.View.AddSubview(moviePlayer.View);

                    //set the view to be full screen and show animated
                    moviePlayer.SetFullscreen(false, true);

                    //Disable the pinch-to-zoom gesture
                    moviePlayer.ControlStyle = MPMovieControlStyle.Embedded;

                    //MPMoviePlayer must be set to PrepareToPlay before playback
                    moviePlayer.PrepareToPlay();

                    //Play Movie
                    moviePlayer.Play();
                }
                catch
                {
                    Console.WriteLine("There was a problem playing back Video");
                }
            }
        }
Ejemplo n.º 21
0
        public Task <string> PlayVideo(string videoPath)
        {
            var task = new TaskCompletionSource <string>();

            try
            {
                if (videoPath != null)
                {
                    var moviePlayer = new MPMoviePlayerController(new NSUrl(videoPath));
                    GetController().View.AddSubview(moviePlayer.View);
                    moviePlayer.SetFullscreen(true, true);
                    moviePlayer.Play();
                }
            }
            catch (Exception ex)
            {
                task.SetException(ex);
            }
            return(task.Task);
        }
        public override void ViewDidLoad()
        {

            base.ViewDidLoad();

            //Button Events
            playMovieButton.TouchUpInside += delegate
            {

                try
                {
                    //Set already instantiated MPMoviePlayerController to playback from Movies/file.m4v
                    mp = new MPMoviePlayerController(NSUrl.FromFilename("Movies/file.m4v"));

                    //enable AirPlay
                    mp.AllowsAirPlay = true;

                    //Add the MPMoviePlayerController View
                    this.View.AddSubview(mp.View);

                    //set the view to be full screen and show animated
                    mp.SetFullscreen(true, true);

                    //Disable the pinch-to-zoom gesture
                    mp.ControlStyle = MPMovieControlStyle.Fullscreen;

                    //MPMoviePlayer must be set to PrepareToPlay before playback
                    mp.PrepareToPlay();

                    //Play Movie
                    mp.Play();
                }
                catch
                {
                    Console.WriteLine("There was a problem playing back Video");
                }

            };

        }
Ejemplo n.º 23
0
        public void Open(string uri)
        {
            // first define the Online Video URL you want to play
            var urltoplay = new NSUrl("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4");

            this.moviePlayer = new MPMoviePlayerController();
            // set the URL to the Video Player
            this.moviePlayer.ContentUrl = urltoplay;
            this.moviePlayer.View.Frame = new CGRect(55, 170, 310f, 200f);
            // Set this property True if you want the video to be auto played on page load
            this.moviePlayer.ShouldAutoplay = false;
            // 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.
            this.moviePlayer.PrepareToPlay();
            // Enable the embeded video controls of the Video Player, this has several types of Embedded controls for you to choose
            this.moviePlayer.ControlStyle = MPMovieControlStyle.Embedded;

            View.AddSubview(this.moviePlayer.View);

            // To play full screen
            moviePlayer.SetFullscreen(true, true);
        }
Ejemplo n.º 24
0
        public override void WillMoveToSuperview(UIView newsuper)
        {
            if (newsuper == null)
            {
                return;
            }
            this.BackgroundColor       = UIColor.Black;
            lblLoading                 = new UILabel(new CGRect(20, 20, 100, 100));
            lblLoading.BackgroundColor = UIColor.Clear;
            lblLoading.Text            = "Loading";
            lblLoading.TextColor       = UIColor.White;
            lblLoading.Font            = (UIFont)(UIFont.FromName("Helvetica", 17f));
            this.AddSubview(lblLoading);
            notificationObserver = NSNotificationCenter.DefaultCenter
                                   .AddObserver(new NSString("MPMoviePlayerPlaybackDidFinishNotification"), WillExitFullScreen);
            mp = new MPMoviePlayerController(MovieUrl);
            mp.ControlStyle = MPMovieControlStyle.Fullscreen;
            mp.View.Frame   = (CGRect)this.Bounds;
            mp.SetFullscreen(true, true);
            this.AddSubview(mp.View);

            mp.Play();
        }
		void HandleMediaFileSelected (object sender, FileSelectedEventArgs args)
		{
			NavigationController.PopToViewController (this,true);

			try {
				var player = new MPMoviePlayerController(NSUrl.FromFilename(args.File)) {
					AllowsAirPlay = true
				};

				View.AddSubview (player.View);
				player.SetFullscreen (true, true);
				player.PrepareToPlay ();
				player.Play ();
			} catch (Exception ex) {
				string message = string.Format ("Error during playback of {0}: {1}", Path.GetFileName(args.File), ErrorHandling.GetExceptionDetailedText(ex) );
				LogMessage (message);
			}
		}
Ejemplo n.º 26
0
        public override void WillMoveToSuperview(UIView newsuper)
        {
            if (newsuper == null)
                return;
            this.BackgroundColor = UIColor.Black;
            lblLoading= new UILabel(new RectangleF(20,20,100,100));
            lblLoading.BackgroundColor = UIColor.Clear;
            lblLoading.Text = "Loading";
            lblLoading.TextColor = UIColor.White;
            lblLoading.Font = UIFont.FromName ("Helvetica", 17f);
            this.AddSubview(lblLoading);
            notificationObserver  = NSNotificationCenter.DefaultCenter
                    .AddObserver("MPMoviePlayerPlaybackDidFinishNotification", WillExitFullScreen );
            mp = new MPMoviePlayerController (MovieUrl);
            mp.ControlStyle = MPMovieControlStyle.Fullscreen;
            mp.View.Frame = this.Bounds;
            mp.SetFullscreen(true,true);
            this.AddSubview(mp.View);

            mp.Play();
        }