protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			// Carega o layout "main" na view principal
			SetContentView (Resource.Layout.Main);

			// Pega o botão do recurso de layout e coloca um evento nele
			Button button = FindViewById<Button> (Resource.Id.button);

			vv = FindViewById<VideoView> (Resource.Id.video_view);
			pb = FindViewById<ProgressBar> (Resource.Id.progress_bar);
			MediaController mc = new MediaController(this);
			mp = new MediaPlayer ();

			pb.SetOnTouchListener (this);

			var uri = Android.Net.Uri.Parse ("http://3gpfind.com/vid/load/Movie%20Trailer/Predators(3gpfind.com).3gp");
			vv.SetOnPreparedListener (this);
			vv.SetVideoURI(uri);
			vv.SetMediaController(mc);
			mc.SetMediaPlayer(vv);
			mc.SetAnchorView(vv);

			button.Click += delegate {
				mc.Show();
				if (!ready)
				{
					holder = vv.Holder;
					holder.SetType (SurfaceType.PushBuffers);
					holder.AddCallback(this);
					mp.SetDataSource(this, uri);
					mp.SetOnPreparedListener(this);
					mp.Prepare();
					ready = true;
				}

				mp.Start();
//				vv.Start();

				Toast.MakeText (this, "Video Started", ToastLength.Short).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);
            }
        }
Exemplo n.º 3
0
		protected override void OnCreate (Bundle icicle)
		{
			//base.OnCreate(icicle);
			if (!LibsChecker.CheckVitamioLibs (this))
				return;
			SetContentView (Resource.Layout.videobuffer);
			mVideoView = FindViewById<VideoView> (Resource.Id.buffer);
			pb = FindViewById<ProgressBar> (Resource.Id.probar);

			downloadRateView = FindViewById<TextView> (Resource.Id.download_rate);
			loadRateView = FindViewById<TextView> (Resource.Id.load_rate);
			if (path == "") {
				// Tell the user to provide a media file URL/path.
				Toast.MakeText (this, "Please edit VideoBuffer Activity, and set path" + " variable to your media file URL/path", ToastLength.Long).Show ();
				return;
			} else {
				//      
				//       * Alternatively,for streaming media you can use
				//       * mVideoView.setVideoURI(Uri.parse(URLstring));
				//       
				uri = Android.Net.Uri.Parse (path);
				mVideoView.SetVideoURI (uri);
				mVideoView.SetMediaController (new MediaController (this));
				mVideoView.RequestFocus ();
				mVideoView.SetOnInfoListener (this);
				mVideoView.SetOnBufferingUpdateListener (this);
				mVideoView.Prepared += (object sender, MediaPlayer.PreparedEventArgs e) => {
					e.P0.SetPlaybackSpeed(1.0f);
				};
			}
		}
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.upload_video_layout);
            context = this;

            Button buttonSelect = FindViewById<Button> (Resource.Id.button2);
            Button buttonUpload = FindViewById<Button> (Resource.Id.button);
            videoView = FindViewById<VideoView> (Resource.Id.videoView);
            videoView.SetMediaController (new Android.Widget.MediaController (this));
            videoView.RequestFocus ();

            buttonSelect.Click += delegate {
                if(videoView != null)
                    videoView.Pause();
                Intent intent = new Intent (Intent.ActionPick, Android.Provider.MediaStore.Video.Media.ExternalContentUri);
                StartActivityForResult (intent, 0);
            };

            buttonUpload.Click += delegate {
                if(videoView != null) {
                    if(videoView.IsPlaying) {
                        videoView.Pause();
                    }
                    new UploadTask(context).Execute(new Java.Lang.Object[]{GetPathFromUri(uri)});
                }
            };
        }
Exemplo n.º 5
0
        private void SetAreTransportControlsEnabled()
        {
            if (Element.NativeControls)
            {
                _mediaController = new MediaController(Context);
                _mediaController.SetMediaPlayer(_videoView);
                _videoView.SetMediaController(_mediaController);
            }
            else
            {
                _videoView.SetMediaController(null);

                if (_mediaController != null)
                {
                    _mediaController.SetMediaPlayer(null);
                    _mediaController = null;
                }
            }
        }
Exemplo n.º 6
0
        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;
                }
            }
        }
        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 Init()
        {
            try
            {
                #region initialize
                statusTitle = Intent.GetStringExtra("title");
                videoPath   = Intent.GetStringExtra("videoUrl");
                ID          = Intent.GetIntExtra("videoId", -1);

                TextView     videoTitle                 = FindViewById <TextView>(Resource.Id.toolbar_title);
                VideoView    videoView                  = FindViewById <VideoView>(Resource.Id.full_screen_video);
                LinearLayout btnShareVideo              = FindViewById <LinearLayout>(Resource.Id.btn_share);
                LinearLayout btnShareVideoWithWhatsapp  = FindViewById <LinearLayout>(Resource.Id.btn_share_whatsapp);
                LinearLayout btnShareVideoWithInstagram = FindViewById <LinearLayout>(Resource.Id.btn_share_instagram);
                LinearLayout btnShareVideoWithFacebook  = FindViewById <LinearLayout>(Resource.Id.btn_share_facebook);
                LinearLayout btnDownloadVideo           = FindViewById <LinearLayout>(Resource.Id.btn_download);
                LinearLayout btnLikeVideo               = FindViewById <LinearLayout>(Resource.Id.btn_like);
                progress = FindViewById <ProgressBar>(Resource.Id.loading);
                imgLike  = FindViewById <ImageView>(Resource.Id.img_like);
                imgCover = FindViewById <ImageView>(Resource.Id.img_cover);

                videoTitle.Text = statusTitle;
                Glide.With(this).Load(Intent.GetStringExtra("coverUrl")).Into(imgCover);

                if (Preferences.ContainsKey("favorites", ID.ToString()))
                {
                    imgLike.SetImageResource(Resource.Drawable.heart);
                }

                videoView.SetVideoPath(Intent.GetStringExtra("videoUrl"));
                videoView.SetMediaController(new MediaController(this));
                videoView.SetOnPreparedListener(this);
                videoView.SetOnCompletionListener(this);
                videoView.SetOnErrorListener(this);

                LoadAds();

                int catId = Intent.GetIntExtra("catId", -1);
                SupportFragmentManager.BeginTransaction().Replace(Resource.Id.frameLayout, new VideosFragment(catId != -1 ? catId : 3)).Commit();
                #endregion

                #region Buttons Click Events
                btnShareVideoWithWhatsapp.Click  += BtnShareOnWhatsapp_Click;
                btnShareVideoWithInstagram.Click += BtnShareOnInstagram_Click;
                btnShareVideoWithFacebook.Click  += BtnShareOnFacebook_Click;
                btnShareVideo.Click    += BtnShareVideo_Click;
                btnDownloadVideo.Click += BtnDownloadVideo_Click;
                btnLikeVideo.Click     += BtnLikeVideo_Click;
                #endregion
            }
            catch
            {
                Toast.MakeText(this, GetString(Resource.String.error), ToastLength.Short).Show();
            }
        }
Exemplo n.º 9
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View v = inflater.Inflate(Resource.Layout.fragment_hello_moon, container, false);

            mPlayButton        = (Button)v.FindViewById(Resource.Id.hellomoon_playButton);
            mPlayButton.Click += (object sender, EventArgs e) => {
                mPlayer.Play(Activity);
            };

            mStopButton        = (Button)v.FindViewById(Resource.Id.hellomoon_stopButton);
            mStopButton.Click += (object sender, EventArgs e) => {
                mPlayer.Stop();
            };

            mPauseButton        = (Button)v.FindViewById(Resource.Id.hellomoon_pauseButton);
            mPauseButton.Click += (object sender, EventArgs e) => {
                mPlayer.Pause();
            };

//			string fileName = "http://johnnygold.com/PigsInAPolka1943.mp4"; //Works from web
            string fileName = "android.resource://" + Activity.PackageName + "/" + Resource.Raw.apollo_17_strollnexus;             // Now works from device.

            Activity.Window.SetFormat(Android.Graphics.Format.Translucent);
            mVideoView = (VideoView)v.FindViewById(Resource.Id.videoView);
            MediaController controller = new MediaController(Activity);

            mVideoView.SetMediaController(controller);
            mVideoView.RequestFocus();
            Android.Net.Uri uri = Android.Net.Uri.Parse(fileName);
            mVideoView.SetVideoURI(uri);

//			mVideoView.Start();

            // Not needed with MediaController
//			vPlayButton = (Button)v.FindViewById(Resource.Id.hellomoon_vPlayButton);
//			vPlayButton.Click += (object sender, EventArgs e) => {
//				mVideoView.Start();
//				vPauseButton.Enabled = true;
//			};
//
//			vStopButton = (Button)v.FindViewById(Resource.Id.hellomoon_vStopButton);
//			vStopButton.Click += (object sender, EventArgs e) => {
//				mVideoView.StopPlayback();
//				vPauseButton.Enabled = false;
//				mVideoView.SetVideoURI(Android.Net.Uri.Parse(fileName));
//			};
//
//			vPauseButton = (Button)v.FindViewById(Resource.Id.hellomoon_vPauseButton);
//			vPauseButton.Click += (object sender, EventArgs e) => {
//				vPauseButton.Enabled = false;
//				mVideoView.Pause();
//			};

            return(v);
        }
Exemplo n.º 10
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View v = inflater.Inflate(Resource.Layout.fragment_hello_moon, container, false);

            mPlayButton = (Button)v.FindViewById(Resource.Id.hellomoon_playButton);
            mPlayButton.Click += (object sender, EventArgs e) => {
                mPlayer.Play(Activity);
            };

            mStopButton = (Button)v.FindViewById(Resource.Id.hellomoon_stopButton);
            mStopButton.Click += (object sender, EventArgs e) => {
                mPlayer.Stop();
            };

            mPauseButton = (Button)v.FindViewById(Resource.Id.hellomoon_pauseButton);
            mPauseButton.Click += (object sender, EventArgs e) => {
                mPlayer.Pause();
            };

            //			string fileName = "http://johnnygold.com/PigsInAPolka1943.mp4"; //Works from web
            string fileName = "android.resource://" + Activity.PackageName + "/" + Resource.Raw.apollo_17_strollnexus; // Now works from device.

            Activity.Window.SetFormat(Android.Graphics.Format.Translucent);
            mVideoView = (VideoView)v.FindViewById(Resource.Id.videoView);
            MediaController controller = new MediaController(Activity);
            mVideoView.SetMediaController(controller);
            mVideoView.RequestFocus();
            Android.Net.Uri uri = Android.Net.Uri.Parse(fileName);
            mVideoView.SetVideoURI(uri);

            //			mVideoView.Start();

            // Not needed with MediaController
            //			vPlayButton = (Button)v.FindViewById(Resource.Id.hellomoon_vPlayButton);
            //			vPlayButton.Click += (object sender, EventArgs e) => {
            //				mVideoView.Start();
            //				vPauseButton.Enabled = true;
            //			};
            //
            //			vStopButton = (Button)v.FindViewById(Resource.Id.hellomoon_vStopButton);
            //			vStopButton.Click += (object sender, EventArgs e) => {
            //				mVideoView.StopPlayback();
            //				vPauseButton.Enabled = false;
            //				mVideoView.SetVideoURI(Android.Net.Uri.Parse(fileName));
            //			};
            //
            //			vPauseButton = (Button)v.FindViewById(Resource.Id.hellomoon_vPauseButton);
            //			vPauseButton.Click += (object sender, EventArgs e) => {
            //				vPauseButton.Enabled = false;
            //				mVideoView.Pause();
            //			};

            return v;
        }
Exemplo n.º 11
0
 protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     // Set our view from the "main" layout resource
     SetContentView(Resource.Layout.VideoActivity);
     videoView = FindViewById <VideoView> (Resource.Id.SampleVideoView);
     videoView.SetMediaController(new MediaController(this));
     videoView.SetVideoPath($"android.resource://{PackageName}/{Resource.Raw.bunny}");
     videoView.RequestFocus();
     videoView.Start();
 }
Exemplo n.º 12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestedOrientation = Android.Content.PM.ScreenOrientation.Landscape;
            base.OnCreate(savedInstanceState);

            castSessionManagerListener = new CastSessionManagerListener(this);
            castContext = CastContext.GetSharedInstance(this);
            castSession = castContext.SessionManager.CurrentCastSession;
            castContext.SessionManager.AddSessionManagerListener(castSessionManagerListener);

            //setup layout and video data
            SetContentView(Resource.Layout.playerPageLayout);
            mediaInfo = chromecastService.Value.GetPlaybackAsset();

            //TITLE
            assetTitle          = FindViewById <TextView>(Resource.Id.assetTitle);
            assetTitle.Text     = mediaInfo.DisplayName;
            assetTitle.TextSize = 20;

            //BACKBUTTON
            backButton        = FindViewById <Button>(Resource.Id.backButton);
            backButton.Click += BackButton_Click;

            //Cast Button setup
            castButton = (MediaRouteButton)FindViewById(Resource.Id.media_route_button);
            CastButtonFactory.SetUpMediaRouteButton(ApplicationContext, castButton);

            //VideoPlayer Source
            videoView = FindViewById <VideoView>(Resource.Id.video_view);
            var videoURL = Android.Net.Uri.Parse(mediaInfo.SourceURL);

            mController = new Android.Widget.MediaController(this);
            mController.SetAnchorView(videoView);
            videoView.SetVideoURI(videoURL);
            videoView.SetMediaController(mController);

            if (mLocation == PlaybackLocation.LOCAL)
            {
                videoView.Start();
            }
            else
            {
                castSession = castContext.SessionManager.CurrentCastSession;
                if ((castSession != null) && (castSession.IsConnected == true))
                {
                    //setup media to send to cast receiver
                    mLocation = PlaybackLocation.REMOTE;
                    var test = castContext.SessionManager.CurrentCastSession;

                    //call/initialize customCastMediaManager if needed. this sample uses default things
                }
            }
        }
Exemplo n.º 13
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.VideoPlayer);

            // Create your application here
            VideoView videoPlayer = (VideoView)FindViewById <VideoView>(Resource.Id.videoView1);
            TextView  pathText    = FindViewById <TextView>(Resource.Id.pathText);

            //Android.Net.Uri uri = Android.Net.Uri.Parse("https://digitalb2017q3dev.blob.core.windows.net/prg-67/video/Black%20Label%20Ralph.mp4");
            //var uri = Android.Net.Uri.Parse("https://redirector.googlevideo.com/videoplayback?mm=31,29&signature=4012B0B76402679A1A9A6D0F379E2A44071A09CC.D2FA83083D17BD14AF4FC5DE9428DB5957C9AA1A&mn=sn-5hnekn7d,sn-5hne6nsd&ratebypass=yes&ipbits=0&key=yt6&ip=93.158.200.189&fvip=1&requiressl=yes&source=youtube&lmt=1508369789111750&dur=629.887&expire=1529529148&mt=1529507274&mv=u&ei=3G4qW5O4H9uKgAfP46uIBg&id=o-AF2e7eqorcJX7dh4KoXFTkffRSPnLxxE9825cQsZTAqf&ms=au,rdu&fexp=23709359&c=WEB&pl=26&mime=video/mp4&sparams=dur,ei,id,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,pl,ratebypass,requiressl,source,expire&itag=22&title=2018-Lincoln-Continental---FULL-REVIEW");
            //https://www.youtube.com/watch?v=edhzKV_Ul7c
            //videoPlayer.SetVideoURI(uri);

            //string appDir = Application.Context.GetExternalFilesDir(null).AbsolutePath;
            //string appDir = Application.Context.GetExternalFilesDir(Android.OS.Environment.DirectoryMovies).ToString();
            //Java.IO.File appDir = Application.Context.GetExternalFilesDir(Android.OS.Environment.DirectoryMovies);
            //Java.IO.File file = new Java.IO.File(appDir, "Black-Label-Ralph.mp4");

            string appDir = (string)Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryMovies);

            var dlPath = Path.Combine(appDir, "/Black-Label-Ralph.mp4");

            var files = Directory.GetFiles(appDir);

            foreach (var file in files)
            {
                pathText.Text += file + " - ";
            }

            //var uri = Android.Net.Uri.Parse(dlPath);

            //My just in case Video lol
            //var uri = Android.Net.Uri.Parse("android.resource://" + Application.PackageName + "/" + Resource.Raw.Black);

            //Show the path in the TextView
            //pathText.Text = appDir + "/Black-Label-Ralph.mp4";

            MediaController mediaController = new MediaController(this);

            mediaController.SetAnchorView(videoPlayer);
            // Set video link (mp4 format )
            //var video = Android.Net.Uri.Parse("http://ia800500.us.archive.org/33/items/Cartoontheater1930sAnd1950s1/PigsInAPolka1943.mp4");

            videoPlayer.SetMediaController(mediaController);


            //videoPlayer.SetVideoURI(uri);
            videoPlayer.SetVideoURI(Android.Net.Uri.Parse(appDir + "/Black-Label-Ralph.mp4"));

            videoPlayer.Start();
        }
        public void StartMediaPlayer()
        {
            var sourceUri = Android.Net.Uri.Parse("https://shravanj.com/files/dev/vid.mp4");

            videoView.SetVideoURI(sourceUri);
            videoView.Visibility = ViewStates.Visible;
            MediaController mediaController = new MediaController(myContext);

            mediaController.SetAnchorView(videoView);
            videoView.SetMediaController(mediaController);
            videoView.Start();
            System.Diagnostics.Debug.WriteLine("Now playing");
        }
Exemplo n.º 15
0
        protected override void OnStart()
        {
            base.OnStart();

            var path = Intent.GetStringExtra(Constants.VideoPath);
            var uri  = Android.Net.Uri.Parse(path);

            _videoView.SetVideoURI(uri);
            _videoView.SetMediaController(new MediaController(this));
            _videoView.Start();

            Tracker.TrackPlayVideo();
        }
Exemplo n.º 16
0
        private void SetupUserInterface()
        {
            //activity.SetContentView(Resource.Layout.VideoPlayerLayout);
            videoView = view.FindViewById <VideoView>(Resource.Id.videoView);
            //设置视频控制器
            videoView.SetMediaController(new MediaController(Context));

            //设置视频路径
            videoView.SetVideoURI(Uri.Parse((Element as ViewPlayerPage).Url));

            //开始播放视频
            videoView.Start();
        }
Exemplo n.º 17
0
        void SetAreTransportControlsEnabled()
        {
            if (Element.AreTransportControlsEnabled)
            {
                mediaController = new MediaController(Context);
                var count = mediaController.ChildCount;
                mediaController.SetMediaPlayer(videoView);
                count = mediaController.ChildCount;
                mediaController.SetPrevNextListeners(new clicklisten(this, true), new clicklisten(this, false));
                count = mediaController.ChildCount;
                videoView.SetMediaController(mediaController);
            }
            else
            {
                videoView.SetMediaController(null);

                if (mediaController != null)
                {
                    mediaController.SetMediaPlayer(null);
                    mediaController = null;
                }
            }
        }
Exemplo n.º 18
0
        private void VideoPlayerMain()
        {
            var mediaController = new MediaController(this);

            previewVideoPlayer.SetVideoURI(Android.Net.Uri.Parse("http://xonshiz.heliohost.org/unitedhcl/streams/preview_video.mp4"));
            mediaController.SetAnchorView(previewVideoPlayer);
            previewVideoPlayer.SetMediaController(mediaController);
            previewVideoPlayer.RequestFocus();
            Console.WriteLine("Got the focus");
            //this.RequestedOrientation = ScreenOrientation.Landscape;
            //previewVideoPlayer.Visibility = ViewStates.Visible;
            Console.WriteLine("Starting the video");
            previewVideoPlayer.Start();
            Console.WriteLine("Done!");
        }
Exemplo n.º 19
0
        //OnCreate
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            //Suche VideoView
            VideoView   videoView1   = (VideoView)FindViewById(Resource.Id.videoView1);
            ProgressBar progressBar1 = (ProgressBar)FindViewById(Resource.Id.progressBar1);
            TextView    textView1    = (TextView)FindViewById(Resource.Id.textView1);


            //Erzeuge MediaController
            MediaController mediaController = new MediaController(this, true);

            mediaController.SetAnchorView(videoView1);
            videoView1.SetMediaController(mediaController);
            videoView1.SetOnInfoListener(this);

            //übergebene Uri extrahieren
            Uri videoUri = this.Intent.Data;

            //Falls Uri vorhanden --> Starte Video
            if (string.IsNullOrEmpty(this.Intent.DataString) == false)
            {
                //ProgressBar anzeigen und videoView leeren
                textView1.Text          = "Starte Videostream:\n" + videoUri.ToString();
                progressBar1.Visibility = ViewStates.Visible;
                videoView1.Visibility   = ViewStates.Gone;
                videoView1.Visibility   = ViewStates.Visible;

                //Öffne Video Stream
                videoView1.SetVideoURI(videoUri);
                videoView1.Start();
            }
            //Ansonste --> Starte Service
            else
            {
                //Überprüfe ob Service schon läuft


                //Starte Service
                Intent i = new Intent(this, typeof(MainService));
                i.AddFlags(ActivityFlags.NewTask);
                this.StartService(i);
            }
        }
Exemplo n.º 20
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Carega o layout "main" na view principal
            SetContentView(Resource.Layout.Main);

            // Pega o botão do recurso de layout e coloca um evento nele
            Button button = FindViewById <Button> (Resource.Id.button);

            vv = FindViewById <VideoView> (Resource.Id.video_view);
            pb = FindViewById <ProgressBar> (Resource.Id.progress_bar);
            MediaController mc = new MediaController(this);

            mp = new MediaPlayer();

            pb.SetOnTouchListener(this);

            var uri = Android.Net.Uri.Parse("http://3gpfind.com/vid/load/Movie%20Trailer/Predators(3gpfind.com).3gp");

            vv.SetOnPreparedListener(this);
            vv.SetVideoURI(uri);
            vv.SetMediaController(mc);
            mc.SetMediaPlayer(vv);
            mc.SetAnchorView(vv);

            button.Click += delegate {
                mc.Show();
                if (!ready)
                {
                    holder = vv.Holder;
                    holder.SetType(SurfaceType.PushBuffers);
                    holder.AddCallback(this);
                    mp.SetDataSource(this, uri);
                    mp.SetOnPreparedListener(this);
                    mp.Prepare();
                    ready = true;
                }

                mp.Start();
//				vv.Start();

                Toast.MakeText(this, "Video Started", ToastLength.Short).Show();
            };
        }
Exemplo n.º 21
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.OurVideoPlayer);

            // Create your application here
            string videoUrl = Intent.GetStringExtra("videoUrl") ?? "Data not available";;

            VideoPlayer = FindViewById <VideoView>(Resource.Id.LiveVideoMain);

            var mediaController = new MediaController(this);

            VideoPlayer.SetVideoURI(Android.Net.Uri.Parse(videoUrl));
            mediaController.SetAnchorView(VideoPlayer);
            VideoPlayer.SetMediaController(mediaController);
            VideoPlayer.RequestFocus();
            VideoPlayer.Start();
        }
Exemplo n.º 22
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            VIDEO_URL      = Intent.GetStringExtra(BUNDLE_VIDEO_URL);
            videoPlayer    = FindViewById <VideoView>(Resource.Id.videoPlayer);
            txtName        = FindViewById <TextView>(Resource.Id.txtName);
            btClose        = FindViewById <ImageButton>(Resource.Id.btClose);
            pgLoading      = FindViewById <ProgressBar>(Resource.Id.pgLoading);
            txtName.Text   = Path.GetFileName(VIDEO_URL);
            btClose.Click += BtClose_Click;
            Android.Net.Uri url        = Android.Net.Uri.Parse(VIDEO_URL);
            MediaController controller = new MediaController(this);

            controller.SetAnchorView(videoPlayer);
            videoPlayer.SetVideoURI(url);
            videoPlayer.SetMediaController(controller);
            videoPlayer.Prepared += VideoPlayer_Prepared;
        }
Exemplo n.º 23
0
            protected override void OnCreate(Bundle bundle)
            {
                base.OnCreate(bundle);
                SetResult(Result.Ok);
                RequestWindowFeature(WindowFeatures.NoTitle);
                Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen);

                var layout = new LinearLayout(this);

                layout.SetBackgroundColor(Color.Black);
                layout.SetGravity(GravityFlags.Center);

                var view = new VideoView(this);

                if (Intent.Extras == null)
                {
                    Finish();
                    return;
                }
                var videoUri = Intent.Extras.GetString("source");

                if (videoUri == null)
                {
                    Finish();
                    return;
                }

                view.SetVideoPath(videoUri);
                view.Completion += (o, e) => Finish();

                if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb)
                {
                    view.SystemUiVisibility = StatusBarVisibility.Hidden;
                }

                var controller = new FullscreenMediaController(this, view);

                view.SetMediaController(controller);

                layout.AddView(view);
                SetContentView(layout);

                view.Start();
            }
Exemplo n.º 24
0
        private void ButtonClick(string file)
        {
            var uri = Android.Net.Uri.Parse($"content://{ZipFileContentProvider.ContentProviderAuthority}/{file}");

            video.SetVideoURI(uri);

            // add the start/pause controls
            var controller = new MediaController(this);

            controller.SetMediaPlayer(video);
            video.SetMediaController(controller);
            video.Prepared += delegate
            {
                // play the video
                video.Start();
            };

            video.RequestFocus();
        }
Exemplo n.º 25
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_video);

            String videoPath = Intent.GetStringExtra(VIDEO_PATH);

            VideoView = FindViewById <VideoView>(Resource.Id.videoview_video);

            MediaController mediaController = new MediaController(this);

            mediaController.SetAnchorView(VideoView);

            VideoView.SetMediaController(mediaController);
            VideoView.SetVideoPath(videoPath);
            VideoView.SetOnPreparedListener(new MediaPlayerListener());
            VideoView.SetOnCompletionListener(new MediaPlayerListener());
        }
Exemplo n.º 26
0
 /**
  * \brief Callback for interface MediaPlayer.OnPreparedListener
  * @param mediaPlayer
  */
 public void OnPrepared(MediaPlayer mp)
 {
     mMediaControllerLock.Lock();
     mMediaPlayerLock.Lock();
     if ((mMediaController != null) && (mVideoView != null) && (mMediaPlayer != null))
     {
         if (mVideoView.Parent != null)
         {
             mMediaController.SetMediaPlayer(this);
             View anchorView = mVideoView.Parent is View ? (View)mVideoView.Parent : mVideoView;
             mMediaController.SetAnchorView(anchorView);
             mVideoView.SetMediaController(mMediaController);
             mMediaController.Enabled = true;
             try
             {
                 mMediaPlayer.SeekTo(mSeekPosition);
             }
             catch (Exception e)
             {
                 mMediaPlayerLock.Unlock();
                 mMediaControllerLock.Unlock();
                 Log.Error("PikkartFullscreenVideo", "Could not seek to a position");
             }
             if (mAutostart)
             {
                 try
                 {
                     mMediaPlayer.Start();
                     //mAutostart = false;
                 }
                 catch (Exception e)
                 {
                     mMediaPlayerLock.Unlock();
                     mMediaControllerLock.Unlock();
                     Log.Error("PikkartFullscreenVideo", "Could not start playback");
                 }
             }
             mMediaController.Show();
         }
     }
     mMediaPlayerLock.Unlock();
     mMediaControllerLock.Unlock();
 }
Exemplo n.º 27
0
 /// <summary>
 /// Load video
 /// </summary>
 void LoadVideo()
 {
     try
     {
         Galeria galeria = service.HttpGet <Galeria>(constants.Url, constants.GaleriaController, constants.GaleriaMethod, "code=05");
         var     uri     = Android.Net.Uri.Parse(galeria.Url);
         VideoViewMain.SetVideoURI(uri);
         VideoViewMain.RequestFocus();
         VideoViewMain.Start();
         mediaController = new Android.Widget.MediaController(this);
         mediaController.SetMediaPlayer(VideoViewMain);
         VideoViewMain.SetMediaController(mediaController);
         VideoViewMain.RequestFocus();
     }
     catch (Exception)
     {
         AlertDialog("Alerta", "Ha ocurrido un error al intentar cargar el video, intente de nuevo mas tarde");
     }
 }
Exemplo n.º 28
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnElementChanged(ElementChangedEventArgs <AtomVideoPlayer> e)
        {
            base.OnElementChanged(e);

            if (Element == null)
            {
                return;
            }

            videoView = new VideoView(this.Context);
            var vlp = new Android.Widget.RelativeLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);

            vlp.AddRule(LayoutRules.CenterInParent);
            //vlp.AddRule(LayoutRules.AlignParentLeft);
            //vlp.AddRule(LayoutRules.AlignParentRight);
            //vlp.AddRule(LayoutRules.AlignParentBottom);
            videoView.LayoutParameters = vlp;

            //vlp.AddRule(LayoutRules.fill);
            var mc = new MediaController(this.Context);

            videoView.SetMediaController(mc);



            var ctrl = new Android.Widget.RelativeLayout(this.Context);

            ctrl.AddView(videoView);
            SetNativeControl(ctrl);

            ResetVideo();

            if (Element.IsPlaying)
            {
                videoView.Start();
            }
            else
            {
                videoView.StopPlayback();
            }
            mc.Show(0);
        }
Exemplo n.º 29
0
        public static void InitializeMediaController(VideoView vv, int id)
        {
            if (!MainPlaybackSticky.MediaControllerDictionary.ContainsKey(id))
            {
                MainPlaybackSticky.MediaControllerDictionary.Add(id, ExtStickyServ.InitializeMediaController(Android.App.Application.Context));
            }
            vv.SetMediaController(MainPlaybackSticky.MediaControllerDictionary[id]);
            MainPlaybackSticky.MediaControllerDictionary[id].SetAnchorView((View)ViewHelpers.Main.ContentRelativeLayout.Parent);

            try
            {
                MainPlaybackSticky.MediaControllerDictionary[id].Enabled = true;
                MainPlaybackSticky.MediaControllerDictionary[id].Show(10000);
                //MainPlaybackSticky.MediaControllerDictionary[MainActivity.ViewPager.CurrentItem].Show();
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 30
0
        bool IVideoPlayer.LoadScreen(Xamarin.Forms.View view, float screenHeight, string uri)
        {
            videoView = (view as NativeViewWrapper).NativeView as VideoView;
            videoView.SetVideoURI(Android.Net.Uri.Parse(uri));
            videoView.Start();
            CurrentStream   = uri;
            mediaController = new MediaController(videoView.Context);
            mediaController.SetMediaPlayer(videoView);
            videoView.SetMediaController(mediaController);
            for (int i = 0; i < 15; i++)
            {
                if (videoView.IsPlaying)
                {
                    return(true);
                }

                return(false);
            }
            return(false);
        }
Exemplo n.º 31
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Activity_VideoPlayer);

            //Get VideoView by ID
            _videoView = FindViewById <VideoView>(Resource.Id.VideoPlayer);

            //Set MediaController for videoView
            _videoView.SetMediaController(new MediaController(this));

            //Get the URL from the intent.
            var url = Intent.GetStringExtra(IntentExtraKey.Url) ?? "";

            //Set Uri source by parsing url
            _videoView.SetVideoURI(Uri.Parse(url));

            //Start playback
            _videoView.Start();
        }
Exemplo n.º 32
0
        private void InitComponent()
        {
            try
            {
                MediaC = new MediaController(this);
                MediaC.Show(5000);

                ProgressBar            = FindViewById <ProgressBar>(Resource.Id.progress_bar);
                ProgressBar.Visibility = ViewStates.Visible;

                PostVideoView = FindViewById <VideoView>(Resource.Id.videoView);

                MediaC.SetAnchorView(PostVideoView);

                PostVideoView.Completion += PostVideoViewOnCompletion;
                PostVideoView.SetMediaController(MediaC);
                PostVideoView.Prepared += PostVideoViewOnPrepared;
                PostVideoView.CanSeekBackward();
                PostVideoView.CanSeekForward();
                //PostVideoView.KeepScreenOn = true;
                //PostVideoView.BringToFront();
                //PostVideoView.Activated = true;

                PostVideoView.SetAudioAttributes(new AudioAttributes.Builder().SetUsage(AudioUsageKind.Media).SetContentType(AudioContentType.Movie).Build());

                if (VideoUrl.Contains("http"))
                {
                    PostVideoView.SetVideoURI(Uri.Parse(VideoUrl));
                }
                else
                {
                    var file = Uri.FromFile(new File(VideoUrl));
                    PostVideoView.SetVideoPath(file.Path);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 33
0
                public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
                {
                    if (container == null)
                    {
                        // Currently in a layout without a container, so no reason to create our view.
                        return(null);
                    }

                    MediaController = new MediaController(Rock.Mobile.PlatformSpecific.Android.Core.Context);

                    RelativeLayout view = new RelativeLayout(Rock.Mobile.PlatformSpecific.Android.Core.Context);

                    view.LayoutParameters = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
                    view.SetBackgroundColor(Android.Graphics.Color.Black);
                    view.SetOnTouchListener(this);

                    VideoPlayer = new VideoView(Activity);
                    VideoPlayer.SetMediaController(MediaController);
                    VideoPlayer.LayoutParameters = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
                    ((RelativeLayout.LayoutParams)VideoPlayer.LayoutParameters).AddRule(LayoutRules.CenterInParent);

                    ((view as RelativeLayout)).AddView(VideoPlayer);

                    VideoPlayer.SetOnPreparedListener(this);
                    VideoPlayer.SetOnErrorListener(this);

                    ProgressBar = new ProgressBar(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    ProgressBar.Indeterminate = true;
                    ProgressBar.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(0));
                    ProgressBar.LayoutParameters = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                    ((RelativeLayout.LayoutParams)ProgressBar.LayoutParameters).AddRule(LayoutRules.CenterInParent);
                    view.AddView(ProgressBar);
                    ProgressBar.BringToFront();

                    ResultView = new UIResultView(view, new System.Drawing.RectangleF(0, 0, NavbarFragment.GetFullDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels), delegate { TryPlayMedia( ); });

                    return(view);
                }
Exemplo n.º 34
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Window.AddFlags(WindowManagerFlags.Fullscreen);
            Window.ClearFlags(WindowManagerFlags.ForceNotFullscreen);
            ActionBar.Hide();
            SetContentView(Resource.Layout.video_fragment);
            int id = Intent.GetIntExtra(Constants.VIDEO_ID, 0);

            vv = (VideoView)FindViewById(Resource.Id.video);
            MediaController mediaController = new MediaController(this, true);

            vv.SetMediaController(mediaController);
            String uriPath = "android.resource://AlgeTiles.AlgeTiles/" + id;
            var    uri     = Android.Net.Uri.Parse(uriPath);

            mediaController.SetAnchorView(vv);
            //mediaController.Show(2000);
            vv.SetVideoURI(uri);
            vv.RequestFocus();
            vv.Start();
            // Create your application here
        }
Exemplo n.º 35
0
                public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
                {
                    if (container == null)
                    {
                        // Currently in a layout without a container, so no reason to create our view.
                        return null;
                    }

                    MediaController = new MediaController( Rock.Mobile.PlatformSpecific.Android.Core.Context );

                    RelativeLayout view = new RelativeLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    view.LayoutParameters = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent );
                    view.SetBackgroundColor( Android.Graphics.Color.Black );
                    view.SetOnTouchListener( this );

                    VideoPlayer = new VideoView( Activity );
                    VideoPlayer.SetMediaController( MediaController );
                    VideoPlayer.LayoutParameters = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent );
                    ( (RelativeLayout.LayoutParams)VideoPlayer.LayoutParameters ).AddRule( LayoutRules.CenterInParent );

                    ( ( view as RelativeLayout ) ).AddView( VideoPlayer );

                    VideoPlayer.SetOnPreparedListener( this );
                    VideoPlayer.SetOnErrorListener( this );

                    ProgressBar = new ProgressBar( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    ProgressBar.Indeterminate = true;
                    ProgressBar.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( 0 ) );
                    ProgressBar.LayoutParameters = new RelativeLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
                    ( (RelativeLayout.LayoutParams)ProgressBar.LayoutParameters ).AddRule( LayoutRules.CenterInParent );
                    view.AddView( ProgressBar );
                    ProgressBar.BringToFront();

                    ResultView = new UIResultView( view, new System.Drawing.RectangleF( 0, 0, NavbarFragment.GetFullDisplayWidth( ), this.Resources.DisplayMetrics.HeightPixels ), delegate { TryPlayMedia( ); } );

                    return view;
                }
Exemplo n.º 36
0
        public void YoutubeVideo(string id)

        {
            string link = "https://www.youtube.com/watch?v=" + id;



            IEnumerable <VideoInfo> videosInfors = DownloadUrlResolver.GetDownloadUrls(link);



            VideoInfo video = videosInfors.First(infor => infor.VideoType == VideoType.Mp4);



            video_url = video.DownloadUrl;

            video_title = video.Title;

            video_extension = video.VideoExtension;



            video_view.SetVideoURI(Android.Net.Uri.Parse(video.DownloadUrl));



            media_controller = new Android.Widget.MediaController(this);

            media_controller.SetMediaPlayer(video_view);

            video_view.SetMediaController(media_controller);

            video_view.RequestFocus();

            video_view.Start();
        }
Exemplo n.º 37
0
            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;
            }