Ejemplo n.º 1
0
		protected override void OnElementChanged (ElementChangedEventArgs<MyVideoPlayer> e)
		{
			base.OnElementChanged (e);
			if (this.Control == null) {	
				var layoutInflater = (LayoutInflater)Context.GetSystemService(global::Android.Content.Context.LayoutInflaterService);
				this._MainLayout = (Android.Widget.RelativeLayout)layoutInflater.Inflate (VideoSamples.Droid.Resource.Layout.VideoLayout, null);	
				SetNativeControl (this._MainLayout);
			}
			this._MyVideoView = this.Control.FindViewById<MyVideoView>(VideoSamples.Droid.Resource.Id.videoView1);
			// full screen hack?  
			ResizeScreen (true); //this.Element.FullScreen);
			// must set reference to root element
			this._MyVideoView.ParentElement = this.Element;
			// pick controller
			this._MCController = new MediaController (this.Context);
			this._MCController.SetMediaPlayer (this._MyVideoView);
			if (this.Element.AddVideoController) {				
				this._AttachedController = true;
				this._MyVideoView.SetMediaController (this._MCController);
			} else {
				this._AttachedController = false;
			}
			// load file
			this._MyVideoView.LoadFile (this.Element.FileSource);
			if (this.Element.AutoPlay) {
				// play if set to autoplay on load
				this._MyVideoView.Play();
			}
		}
Ejemplo n.º 2
0
		protected override void Dispose (bool disposing)
		{
			if (this._MCController != null && this._MyVideoView != null) {
				this._MyVideoView.SetMediaController (null);
			}
			if (this._MCController != null) {
				this._MCController.Dispose ();
				this._MCController = null;
			}
			if (this._MyVideoView != null) {
				this._MyVideoView.StopPlayback ();
				this._MyVideoView.Dispose ();
				this._MyVideoView = null;
			}
			base.Dispose (disposing);
		}
        protected override void OnElementChanged(ElementChangedEventArgs <MyVideoPlayer> e)
        {
            base.OnElementChanged(e);
            if (this.Control == null)
            {
                this.Element.PlayerAction = (action) => {
                    if (action == VideoState.ActionPause)
                    {
                        this._MyVideoView.Pause();
                    }
                    else if (action == VideoState.ActionPlay)
                    {
                        this._MyVideoView.Start();
                    }
                    else if (action == VideoState.ActionSTOP)
                    {
                        this._MyVideoView.StopPlayback();
                    }
                };

                var layoutInflater = (LayoutInflater)Context.GetSystemService(global::Android.Content.Context.LayoutInflaterService);
                var video          = (Android.Widget.LinearLayout)layoutInflater.Inflate(LabSamples.Droid.Resource.Layout.VideoLayout, null);
                SetNativeControl(video);
            }

            this._MyVideoView = this.Control.FindViewById <MyVideoView>(LabSamples.Droid.Resource.Id.videoView1);

            // must set reference to root element
            this._MyVideoView.RootPlayer = this.Element;

            // pick controller
            if (this.Element.UseBuiltInMediaPlayer)
            {
                this._MCController = new MediaController(this.Context);
                this._MCController.SetMediaPlayer(this._MyVideoView);
                this._MyVideoView.SetMediaController(this._MCController);
            }
            else
            {
                this._MyVideoView.SetZOrderOnTop(true);
                this._MyVideoView.Holder.AddCallback(this);
                this._MPlayer = new MediaPlayer();
            }

            // play
            play(this.Element.FileSource);
        }
        protected override void OnElementChanged(ElementChangedEventArgs <MyVideoPlayer> e)
        {
            base.OnElementChanged(e);
            if (this.Control == null)
            {
                var layoutInflater = (LayoutInflater)Context.GetSystemService(global::Android.Content.Context.LayoutInflaterService);
                this._MainLayout = (Android.Widget.LinearLayout)layoutInflater.Inflate(Resource.Layout.VideoLayout, null);
                SetNativeControl(this._MainLayout);
            }

            this._MyVideoView = this.Control.FindViewById <MyVideoView>(Resource.Id.videoView1);


            // full screen hack?
            ResizeScreen(this.Element.FullScreen); //);

            // must set reference to root element
            this._MyVideoView.ParentElement = this.Element;

            // pick controller
            this._MCController = new MediaController(this.Context);
            this._MCController.SetMediaPlayer(this._MyVideoView);

            if (this.Element.AddVideoController)
            {
                this._AttachedController = true;
                this._MyVideoView.SetMediaController(this._MCController);
            }
            else
            {
                this._AttachedController = false;
            }

            // load file
            //  this._MyVideoView.LoadFile(this.Element.FileSource);
            this._MyVideoView.LoadFile("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4");
            //this._MyVideoView.LoadFile("https://www.facebook.com/TheBearWay/videos/1364470410275596/");
            if (this.Element.AutoPlay)
            {
                // play if set to autoplay on load
                this._MyVideoView.Play();
            }
        }