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(); } }
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); }