public AudioView(Context context, Audio audio, string path, ViewerScreen docView) : base(context) { _audio = audio; _basePath = path; _docView = docView; _audioView = new Android.Widget.VideoView(context); ViewGroup.LayoutParams param = new ViewGroup.LayoutParams(1, 1); _audioView.LayoutParameters = param; if (!File.Exists(System.IO.Path.Combine(_basePath, _audio.Link))) { return; } _audioView.SetVideoPath(System.IO.Path.Combine(_basePath, _audio.Link)); var time = _audioView.CurrentPosition; this.AddView(_audioView); _audioView.RequestFocus(); //playstopclick if (_audio.PlayStopClick) { this.Click += (sender, e) => { this.PlayStop(); }; } //autoplay if (this._audio.Autoplay) { //_audioView.Prepared -= Autoplay; //_audioView.Prepared += Autoplay; _audioView.Prepared += (sender, e) => { _isReady = true; }; } //loop if (_audio.Loop) { _audioView.Completion += (sender, e) => { _audioView.Start(); }; } }
public VideoView(Context context, Video video, string path, ViewerScreen docView) : base(context) { _video = video; _basePath = path; _docView = docView; //this.SetBackgroundColor(Color.Aqua); View.Inflate(this.Context, Resource.Layout.VideoView, this); try { _videoView = FindViewById <Android.Widget.VideoView>(Resource.Id.videoView); _btnFull = FindViewById <ImageButton>(Resource.Id.btnFull); if (video.Link != "") { if (!File.Exists(System.IO.Path.Combine(_basePath, _video.Link))) { return; } _videoView.SetVideoPath(System.IO.Path.Combine(_basePath, _video.Link)); } else if (_video.UrlStream != "") { _videoView.SetVideoURI(Android.Net.Uri.Parse(_video.UrlStream)); } /*MediaController mc = new MediaController(context); * mc.SetMediaPlayer(_videoView); * mc.SetAnchorView(_videoView); * * _videoView.SetMediaController(mc);*/ _videoView.RequestFocus(); } catch (Exception ex) { Utils.WriteLog("Errore video", ex.Message); return; } _videoView.Error += (sender, e) => { return; }; //playstopclick if (this._video.PlayStopClick) { this.Click += (sender, e) => { this.PlayStop(); }; } if (_video.Fullscreen) { _btnFull.Click += (sender, e) => { Intent i = new Intent(); i.SetClass(this.Context, typeof(VideoViewScreen)); i.PutExtra("path", _basePath); i.PutExtra("video", JsonConvert.SerializeObject(_video)); //ActivitiesBringe.SetObject(zoom); this.Stop(); docView.StartActivity(i); }; } else { _btnFull.Visibility = ViewStates.Invisible; } //autoplay if (this._video.Autoplay) { //_videoView.Prepared -= Autoplay; //_videoView.Prepared += Autoplay; _videoView.Prepared += (sender, e) => { _isReady = true; }; if (_video.Delay > 0) { this.Hide(); _isReady = true; } } else { this.Hide(); } //loop if (_video.Loop) { _videoView.Completion += (sender, e) => { _videoView.Start(); }; } //finish _videoView.Completion += (sender, e) => { if (OnFinish != null) { OnFinish(); } }; }