void SetAreTransportControlsEnabled() { if (Element.AreTransportControlsEnabled) { mediaController = new MediaController(Context); mediaController.SetMediaPlayer(videoView); videoView.SetMediaController(mediaController); } else { videoView.SetMediaController(null); if (mediaController != null) { mediaController.SetMediaPlayer(null); mediaController = null; } } }
// ---------------------------------------------- #region Private Methods private void LoadAndPlay() { System.Diagnostics.Debug.WriteLine(_view.Url); if (string.IsNullOrWhiteSpace(_view.Url)) { return; } // Get the video dimensions and calculate sizes GetVideoDimensions(_view.Url); // Create the Media Controller _controller = new MediaController(Forms.Context, true); _videoview.SetMediaController(_controller); _controller.SetMediaPlayer(_videoview); _controller.SetAnchorView(_videoview); // Receive Callbacks for the surface _videoview.Holder.AddCallback(this); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); this.Window.AddFlags(WindowManagerFlags.Fullscreen); _video = JsonConvert.DeserializeObject <Video>(Intent.GetStringExtra("video")); _basePath = Intent.GetStringExtra("path"); Android.Widget.VideoView videoView = new Android.Widget.VideoView(this); ViewGroup.LayoutParams param = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); videoView.LayoutParameters = param; //var uri = Android.Net.Uri.Parse(System.IO.Path.Combine(path, _video.Link)); if (_video.Link.StartsWith("http:")) { videoView.SetVideoURI(Android.Net.Uri.Parse(_video.Link)); //_videoView.SetBackgroundColor(Color.Fuchsia); } else { videoView.SetVideoPath(System.IO.Path.Combine(_basePath, _video.Link)); } //videoView.SetBackgroundColor(Color.Black); _contentView.SetBackgroundColor(Color.Black); MediaController mc = new MediaController(this); videoView.SetMediaController(mc); mc.RequestFocus(); _contentView.AddView(videoView); videoView.Start(); }