/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName == "Source") { ResetVideo(); } if (e.PropertyName == "IsPlay") { if (Element.IsPlay) { videoView.Start(); } else { videoView.StopPlayback(); } } if (e.PropertyName == nameof(AtomVideoPlayer.IsVisible)) { if (!Element.IsVisible) { videoView.StopPlayback(); videoView.Visibility = ViewStates.Gone; } else { videoView.Start(); videoView.Visibility = ViewStates.Visible; } } }
void SetSource() { isPrepared = false; bool hasSetSource = false; if (Element.Source is UriVideoSource) { string uri = (Element.Source as UriVideoSource).Uri; if (!String.IsNullOrWhiteSpace(uri)) { videoView.SetVideoURI(Android.Net.Uri.Parse(uri)); hasSetSource = true; } } else if (Element.Source is FileVideoSource) { string filename = (Element.Source as FileVideoSource).File; if (!String.IsNullOrWhiteSpace(filename)) { videoView.SetVideoPath(filename); hasSetSource = true; } } if (hasSetSource && Element.AutoPlay) { videoView.Start(); } }
protected override void OnResume() { try { base.OnResume(); if (Settings.BackgroundScreenWelcomeType == "Video") { if (!VideoViewer.IsPlaying) { VideoViewer.Start(); } VideoViewer.Completion += VideoViewer_Completion; } secTermTextView.Click += SecTermTextView_Click; secPrivacyTextView.Click += SecPrivacyTextView_Click; RegisterButton.Click += RegisterButton_Click; LoginButton.Click += LoginButton_Click; } catch (Exception exception) { Crashes.TrackError(exception); } }
private void OnVideoCompletion(object sender, EventArgs e) { if (!_disposed && _videoView != null) { _videoView.Start(); } }
void SetSource() { isPrepared = false; bool hasSetSource = false; if (Element.Source is UriVideoSource) { string uri = (Element.Source as UriVideoSource).Uri; if (!String.IsNullOrWhiteSpace(uri)) { videoView.SetVideoURI(Android.Net.Uri.Parse(uri)); hasSetSource = true; } } else if (Element.Source is ResourceVideoSource) { string package = Context.PackageName; string path = (Element.Source as ResourceVideoSource).Path; if (!String.IsNullOrWhiteSpace(path)) { string filename = Path.GetFileNameWithoutExtension(path).ToLowerInvariant(); string uri = "android.resource://" + package + "/raw/" + filename; videoView.SetVideoURI(Android.Net.Uri.Parse(uri)); hasSetSource = true; } } if (hasSetSource && Element.AutoPlay) { videoView.Start(); } }
private void VideoViewer_Completion(object sender, EventArgs e) { try { VideoViewer.Start(); } catch (Exception exception) { Console.WriteLine(exception); } }
public bool OnInfo(MediaPlayer mp, int what, int extra) { switch (what) { case MediaPlayer.MediaInfoBufferingStart: if (mVideoView.IsPlaying) { mVideoView.Pause(); pb.Visibility = ViewStates.Visible; downloadRateView.Text = ""; loadRateView.Text = ""; downloadRateView.Visibility = ViewStates.Visible; loadRateView.Visibility = ViewStates.Visible; } break; case MediaPlayer.MediaInfoBufferingEnd: mVideoView.Start(); pb.Visibility = ViewStates.Gone; downloadRateView.Visibility = ViewStates.Gone; loadRateView.Visibility = ViewStates.Gone; break; case MediaPlayer.MediaInfoDownloadRateChanged: downloadRateView.Text = "" + extra + "kb/s" + " "; break; } return(true); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); //Hides action bar RequestWindowFeature(WindowFeatures.NoTitle); SetContentView(Resource.Layout.activity_videoplayer); VideoView videoView = FindViewById <VideoView> (Resource.Id.videoView); videoView.Completion += delegate { //Activity sluiten wanneer video afgespeeld is this.Finish(); }; MediaController mediaController = new MediaController(this); mediaController.SetAnchorView(videoView); videoView.SetMediaController(mediaController); try { string pathToVideo = Intent.GetStringExtra("PathToVideo"); var uri = Android.Net.Uri.Parse(pathToVideo); videoView.SetVideoURI(uri); videoView.Start(); } catch (Exception ex) { Insights.Report(ex); this.RunOnUiThread(new Action(() => { Toast.MakeText(this, "Het openen van de video is mislukt. Probeer het a.u.b. opnieuw.", ToastLength.Long).Show(); })); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab); fab.Click += FabOnClick; CheckBox checkbox = FindViewById <CheckBox>(Resource.Id.checkbox01); checkbox.Click += (o, e) => { if (checkbox.Checked) { Toast.MakeText(this, "Selected", ToastLength.Short).Show(); } else { Toast.MakeText(this, "Not selected", ToastLength.Short).Show(); } }; ImageView imageview01 = FindViewById <ImageView>(Resource.Id.image01); VideoView videoView = FindViewById <VideoView>(Resource.Id.videoView1); var uri = Android.Net.Uri.Parse("https://file-examples.com/wp-content/uploads/2017/04/file_example_MP4_480_1_5MG.mp4"); videoView.SetVideoURI(uri); videoView.Visibility = ViewStates.Visible; videoView.Start(); }
private void OnVideoViewPrepared(object sender, EventArgs args) { if (Element.AutoPlay) { videoView.Start(); } }
public void SetContent(string url) { // https://stackoverflow.com/questions/47353986/xamarin-forms-forms-context-is-obsolete //SOLVED BY REFERENCING LOCAL ANDROID CONTEXT IN MAIN APPLICATION //REPLACED FORMS.CONTEXT videoView = new VideoView(MainApplication.ActivityContext); mediaController = new MediaController(MainApplication.ActivityContext, false); uriHd = Android.Net.Uri.Parse(url); mediaController.SetMediaPlayer(videoView); mediaController.SetAnchorView(videoView); videoView.SetMediaController(mediaController); videoView.SetFitsSystemWindows(true); videoView.SetVideoURI(uriHd); contentView = new ContentView(); //contentView.BackgroundColor = Color.Black; contentView.Content = videoView.ToView(); contentView.HorizontalOptions = LayoutOptions.FillAndExpand; contentView.VerticalOptions = LayoutOptions.CenterAndExpand; Content = contentView; videoView.Start(); }
protected override void OnResume() { try { base.OnResume(); if (AppSettings.BackgroundScreenWelcomeType == "Video") { if (!VideoViewer.IsPlaying) { VideoViewer.Start(); } VideoViewer.Completion += VideoViewer_Completion; } RegisterButton.Click += RegisterButton_Click; LoginButton.Click += LoginButton_Click; ContinueButton.Click += ContinueButtonOnClick; } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var jsonString = this.Arguments.GetString(VoteVidoeTypeFragment_KEY); var vote = Newtonsoft.Json.JsonConvert.DeserializeObject <Vote> (jsonString); View rootView = inflater.Inflate(Resource.Layout.votedescview_type02, container, false); MediaController mc = new MediaController(Activity); _videoView = rootView.FindViewById <VideoView> (Resource.Id.votedescview_type02_player); _videoView.Prepared += (sender, e) => { _videoView.Start(); }; var uri = Android.Net.Uri.Parse(vote.VideoUrl); _videoView.SetVideoURI(uri); _videoView.SetMediaController(mc); var textView = rootView.FindViewById <TextView> (Resource.Id.votedescview_type02_lbDesc); textView.Text = vote.Description; return(rootView); }
protected override void OnElementChanged(ElementChangedEventArgs <View> e) { base.OnElementChanged(e); var crossVideoPlayerView = Element as CrossVideoPlayerView; if ((crossVideoPlayerView != null) && (e.OldElement == null)) { var metrics = Resources.DisplayMetrics; crossVideoPlayerView.HeightRequest = metrics.WidthPixels / metrics.Density / crossVideoPlayerView.VideoScale; var videoView = new VideoView(Context); var uri = Android.Net.Uri.Parse(crossVideoPlayerView.VideoSource); videoView.SetVideoURI(uri); var mediaController = new MediaController(Context); mediaController.SetAnchorView(videoView); videoView.SetMediaController(mediaController); videoView.Start(); SetNativeControl(videoView); } }
//public override void OnStart() //{ // base.OnStart(); // videoView.Prepared += OnVideoPlayerPrepared; // Play("MyVids/PreviewCourse.mp4"); //} //public override void OnStop() //{ // base.OnStop(); // videoView.Prepared -= OnVideoPlayerPrepared; //} //private void OnVideoPlayerPrepared(object sender, EventArgs e) //{ // mediaController.SetAnchorView(videoView); // //show media controls for 3 seconds when video starts to play // mediaController.Show(3000); //} //private async void GetVideo() //{ // try // { // using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", ""))) // { // BoxService.InitializeClient(client); // var o_data = new ServiceResponseObject<SuccessResponse>(); // o_data = await BoxService.GetVideo(id); // if (o_data.Status == HttpStatusCode.OK) // { // video_url = o_data.ResponseData.Message; // PlayVideoMethod(); // //controller = new MediaController(context); // //img_get_video.CanPause(); // // controller.SetAnchorView(img_get_video); // //img_get_video.SetMediaController(controller); // //img_get_video.SetOnPreparedListener(new MediaOPlayerListener(context, img_get_video)); // //controller.Show(50000); // } // else // { // Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show(); // } // } // } // catch (Exception ex) // { // Toast.MakeText(Activity, ex.Message, ToastLength.Long).Show(); // } //} private void PlayVideoMethod() { try { //controller = new MediaController(context); //img_get_video.CanPause(); // controller.SetAnchorView(img_get_video); //img_get_video.SetMediaController(controller); //img_get_video.SetOnPreparedListener(new MediaOPlayerListener(context, img_get_video)); //controller.Show(50000); preloader.Visibility = ViewStates.Visible; var src = Android.Net.Uri.Parse(URL + StaticOrder.File_Name); videoView.SetVideoURI(src); var mediaController = new MediaController(Activity); mediaController.SetAnchorView(videoView); videoView.SetMediaController(mediaController); videoView.SetOnPreparedListener(new MediaOnPlayerListener(mediaController, preloader)); videoView.Start(); } catch (Exception ex) { Toast.MakeText(Activity, ex.Message, ToastLength.Long).Show(); } }
protected override void OnElementChanged(ElementChangedEventArgs<View> e) { base.OnElementChanged(e); var crossVideoPlayerView = Element as CrossVideoPlayerView; if ((crossVideoPlayerView != null) && (e.OldElement == null)) { var metrics = Resources.DisplayMetrics; crossVideoPlayerView.HeightRequest = metrics.WidthPixels/metrics.Density/crossVideoPlayerView.VideoScale; var videoView = new VideoView(Context); var uri = Android.Net.Uri.Parse(crossVideoPlayerView.VideoSource); videoView.SetVideoURI(uri); var mediaController = new MediaController(Context); mediaController.SetAnchorView(videoView); videoView.SetMediaController(mediaController); videoView.Start(); SetNativeControl(videoView); } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Page> e) { base.OnElementChanged(e); if (e.OldElement != null || Element == null) { return; } var layout = new Android.Widget.LinearLayout(this.Context); layout.SetBackgroundColor(Android.Graphics.Color.Black); layout.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent); VideoView mVideoView = new VideoView(Context); mVideoView.SetVideoPath("android.resource://" + this.Context.PackageName + "/" + Resource.Drawable.IntroGladys); layout.SetVerticalGravity(GravityFlags.Center); layout.SetHorizontalGravity(GravityFlags.Center); mVideoView.LayoutParameters = new LayoutParams(LayoutParams.FillParent, LayoutParams.FillParent); layout.AddView(mVideoView); mVideoView.Start(); _view = layout; AddView(_view); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Remove Title this.RequestWindowFeature(WindowFeatures.NoTitle); SetContentView(Resource.Layout.Player); // Button close Button buttonClose = FindViewById <Button>(Resource.Id.buttonClose); // Prevent sleeping this.Window.SetFlags(WindowManagerFlags.KeepScreenOn, WindowManagerFlags.KeepScreenOn); buttonClose.Click += delegate { Finish(); }; videoPlayer = FindViewById <VideoView>(Resource.Id.PlayerVideoView); var url = Intent.GetStringExtra("url") ?? "Not available"; var title = Intent.GetStringExtra("title") ?? "Not available"; Log.println("Video player: " + url); Log.println("Video player: " + title); videoPlayer.SetVideoURI(Android.Net.Uri.Parse(url)); mediaController = new MediaController(this, true); videoPlayer.SetMediaController(mediaController); videoPlayer.Start(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_main); CopyDocuments("baseInterna.sqlite", "LeonaliDB.db"); txtUsuario = (EditText)FindViewById(Resource.Id.txtUsuario); txtPassword = (EditText)FindViewById(Resource.Id.txtContrasena); btnLogin = (Button)FindViewById(Resource.Id.btnLogin); var ln = (LinearLayout)FindViewById(Resource.Id.lnPreguntas); btnLogin.Click += delegate { com.somee.servicioweb1test.Service service = new com.somee.servicioweb1test.Service(); var xml = service.Consulta("select * from usuarios where user_name = '" + txtUsuario.Text + "' and user_password = '******';"); XmlSerializer xmlSerializer = new XmlSerializer(typeof(ClaseDato)); var claseDato = new ClaseDato(); try { var jsonLimpio = ""; var bandera = false; foreach (var item in xml) { if (item == '[') { bandera = true; } if (bandera) { jsonLimpio += item; } if (item == ']') { break; } } var results = JsonConvert.DeserializeObject <List <ClaseDato> >(jsonLimpio); new General().GuardarDatosUsuario(results[0].id_user, results[0].user_name, results[0].user_password); StartActivity(typeof(ActivityMenu)); } catch (Exception ex) { Toast.MakeText(this, "Usuario y/o contraseña son incorrectos", ToastLength.Short).Show(); } }; video = (VideoView)FindViewById(Resource.Id.videoPlay); video.SetOnPreparedListener(this); string videoPaht = "android.resource://CuestionarioDemo.CuestionarioDemo/" + Resource.Raw.agri; Android.Net.Uri uri = Android.Net.Uri.Parse(videoPaht); video.SetVideoURI(uri); video.Start(); }
public void Play() { if (!_prepared) { return; } _videoView.Start(); }
void PlayVideo(object sender, EventArgs arg) { //Start that video!!! var activity = Context as Activity; activity.RunOnUiThread(() => { videoView.Start(); }); }
protected override void OnResume() { base.OnResume(); if (backgroundVideo != null) { backgroundVideo.Start(); } }
private void StartVideo() { mediaController.SetAnchorView(videoView); mediaController.SetMediaPlayer(videoView); String fileName = "android.resource://" + this.Activity.BaseContext.PackageName + "/raw/one"; videoView.SetVideoURI(Android.Net.Uri.Parse(fileName)); videoView.Start(); }
void CamStartPlay_Click(object sender, EventArgs e) { var uri = Android.Net.Uri.Parse("rtsp://*****:*****@192.168.1.34/media/video1"); //Camrender.SetMediaController(new MediaController(this)); Camrender.RequestFocus(); Camrender.SetVideoURI(uri); Camrender.Start(); }
private void SetSource() { _isPrepared = false; var hasSetSource = false; if (Element.Source is UriVideoSource) { var uri = (Element.Source as UriVideoSource).Uri; if (!string.IsNullOrWhiteSpace(uri)) { _videoView.SetVideoURI(Uri.Parse(uri)); hasSetSource = true; } } else if (Element.Source is FileVideoSource) { var filename = (Element.Source as FileVideoSource).File; if (!string.IsNullOrWhiteSpace(filename)) { _videoView.SetVideoPath(filename); hasSetSource = true; } } else if (Element.Source is ResourceVideoSource) { var package = Context.PackageName; var path = (Element.Source as ResourceVideoSource).Path; if (!string.IsNullOrWhiteSpace(path)) { var filename = Path.GetFileNameWithoutExtension(path).ToLowerInvariant(); var uri = "android.resource://" + package + "/raw/" + filename; _videoView.SetVideoURI(Uri.Parse(uri)); hasSetSource = true; } } if (hasSetSource && Element.AutoPlay) { _videoView.Start(); } }
void OpeningVideo() { string APPLICATION_RAW_PATH = "android.resource://com.technificentconsulting.MyCoMobile/"; VideoView videoView = FindViewById <VideoView>(Resource.Id.vwIntroVideo); var Path = (APPLICATION_RAW_PATH + Resource.Raw.opener_vid); videoView.SetVideoURI(Android.Net.Uri.Parse(Path)); videoView.Start(); }
public async Task Play(IMediaFile mediaFile) { VideoViewCanvas.SetVideoURI(Android.Net.Uri.Parse(mediaFile.Url)); var mediaController = new MediaController(Application.Context); mediaController.SetAnchorView(VideoViewCanvas); VideoViewCanvas.SetMediaController(mediaController); VideoViewCanvas.Start(); }
private void Connect() { //http://10.10.10.202/onvif/device_service //rtsp://10.10.10.78/axis-media/media.amp _camera = IPCameraFactory.GetCamera("rtsp://10.10.10.78/axis-media/media.amp", "root", "cavi123,.");// , CameraTransportType.TCP _camera.CameraStateChanged += camera_CameraStateChanged; //_camera.CameraStateChanged += _camera_CameraStateChanged; _connector.Connect(_camera.VideoChannel, _imgHandler); _videoView.SetImageProvider(_imgHandler); _camera.Start(); _videoView.Start(); //ICameraNetworkManager camIp = _camera.NetworkManager; }
private void StartNFCGif() { VideoView anim = FindViewById <VideoView>(Resource.Id.videoView1); anim.SetOnPreparedListener(new VideoLoop()); String uriPath = "android.resource://" + PackageName + "/" + Resource.Drawable.nfctaphere; Android.Net.Uri uri = Android.Net.Uri.Parse(uriPath); anim.SetVideoURI(uri); anim.Start(); }
private void VideoViewer_Completion(object sender, EventArgs e) { try { VideoViewer?.Start(); } catch (Exception exception) { Methods.DisplayReportResultTrack(exception); } }
void UpdatePlayback() { if (Element.Play && !videoView.IsPlaying) { videoView.Start(); } else if (!Element.Play && videoView.IsPlaying) { videoView.StopPlayback(); } }
protected async override void OnCreate (Bundle bundle) { RequestWindowFeature(WindowFeatures.NoTitle); base.OnCreate (bundle); Window.AddFlags(WindowManagerFlags.Fullscreen); Window.ClearFlags(WindowManagerFlags.ForceNotFullscreen); SetContentView (Resource.Layout.VideoViewer); videoView = FindViewById<VideoView>(Resource.Id.videoViewer); videoView.Touch += videoView_Touch; videoView.Prepared += VideoView_Prepared; m_videoPregressTimer = new System.Timers.Timer (); m_videoPregressTimer.Interval = 500; m_videoPregressTimer.Elapsed += T_Elapsed; // advertising setup AdView mAdView = (AdView) this.FindViewById(Resource.Id.adView); AdRequest adRequest = new AdRequest.Builder ().Build (); mAdView.LoadAd(adRequest); string videoID = Intent.Extras.GetString ("videoID"); try { YouTubeUri theURI = await YouTube.GetVideoUriAsync(videoID,YouTubeQuality.Quality720P); var uri = Android.Net.Uri.Parse(theURI.Uri.AbsoluteUri); videoView.SetVideoURI(uri); videoView.Start (); m_videoPregressTimer.Enabled = true; m_videoPregressTimer.Start(); m_videoSourceSet = true; } catch (Exception ex) { Console.WriteLine (ex.ToString ()); } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var jsonString = this.Arguments.GetString (VoteVidoeTypeFragment_KEY); var vote = Newtonsoft.Json.JsonConvert.DeserializeObject<Vote> (jsonString); View rootView = inflater.Inflate (Resource.Layout.votedescview_type02, container, false); MediaController mc = new MediaController (Activity); _videoView = rootView.FindViewById<VideoView> (Resource.Id.votedescview_type02_player); _videoView.Prepared += (sender, e) => { _videoView.Start (); }; var uri = Android.Net.Uri.Parse (vote.VideoUrl); _videoView.SetVideoURI (uri); _videoView.SetMediaController (mc); var textView = rootView.FindViewById<TextView> (Resource.Id.votedescview_type02_lbDesc); textView.Text = vote.Description; return rootView; }