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.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
        private void ResetVideo()
        {
            var source = Element.Source;

            if (source == null)
            {
                videoView.SetVideoURI(null);
                return;
            }

            var filePath = source.FilePath;

            if (filePath != null)
            {
                videoView.SetVideoPath(filePath);
                videoView.SeekTo(1);
                return;
            }

            var fileUri = source.Url;

            if (fileUri != null)
            {
                videoView.SetVideoURI(Android.Net.Uri.Parse(fileUri));
                videoView.SeekTo(1);
                return;
            }
        }
Exemplo n.º 4
0
        void UpdateSource(bool forceSeek = false)
        {
            bool hasSetSource = false;

            if (Element.Source is UriVideoSource)
            {
                string uri = (Element.Source as UriVideoSource).Uri;

                if (!String.IsNullOrWhiteSpace(uri))
                {
                    Android.Net.Uri parsedUri = Android.Net.Uri.Parse(uri);
                    videoView.SetVideoURI(parsedUri);
                    hasSetSource = true;
                }
            }
            else if (Element.Source is FileVideoSource)
            {
                string filename = (Element.Source as FileVideoSource).File;

                if (!String.IsNullOrWhiteSpace(filename))
                {
                    videoView.SetVideoPath(filename);
                    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)
            {
                if (Element.StartTime > 0)
                {
                    videoView.SeekTo(Element.StartTime * 1000);
                }
                else if (forceSeek)
                {
                    videoView.SeekTo(1); // SeekTo(0) does not do anything, so using 1
                }
            }
        }
Exemplo n.º 5
0
        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {

            AlertDialog.Builder dialog = new AlertDialog.Builder(Activity)
                .SetTitle(title)
                .SetPositiveButton("Got it", (sender, args) => { });

            LayoutInflater inflater = Activity.LayoutInflater;
            View view = inflater.Inflate(Resource.Layout.VideoHelpPopup, null);

            video = view.FindViewById<VideoView>(Resource.Id.helper_video);
            descriptionView = view.FindViewById<TextView>(Resource.Id.helper_explanation);
            descriptionView.SetText(description.ToCharArray(),0, description.Length);

            if (!string.IsNullOrEmpty(videoAdd))
            {
                video.Prepared += VideoPrepared;
                video.SetVideoURI(Uri.Parse(videoAdd));
                video.Touch += VideoTouched; 
                video.SetZOrderOnTop(true); // Removes dimming
            }
            else
            {
                LinearLayout holder = view.FindViewById<LinearLayout>(Resource.Id.helper_videoHolder);
                holder.Visibility = ViewStates.Gone;
            }

            dialog.SetView(view);

            return dialog.Create();
        }
Exemplo n.º 6
0
        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();
                }));
            }
        }
Exemplo n.º 7
0
        void SetSource()
        {
            isPrepared          = false;
            hasSetSource        = false;
            videoView.Activated = true;
            videoView.StopPlayback();

            if (Element.Source is UriVideoSource source)
            {
                string uri = source.Uri;

                if (!string.IsNullOrWhiteSpace(uri))
                {
                    videoView.SetVideoURI(Android.Net.Uri.Parse(uri));
                    hasSetSource = true;
                }
            }
            else if (Element.Source is FileVideoSource videoSource)
            {
                string filename = videoSource.File;

                if (!string.IsNullOrWhiteSpace(filename))
                {
                    videoView.SetVideoPath(filename);
                    hasSetSource = true;
                }
            }
        }
Exemplo n.º 8
0
        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.View> e)
        {
            base.OnElementChanged(e);

            //Get LayoutInflater and inflate from axml
            //Important note, this project utilizes a layout-land folder in the Resources folder
            //Android will use this folder with layout files for Landscape Orientations
            //This is why we don't have to worry about the layout of the play button, it doesn't exist in landscape layout file!!! 
            var activity = Context as Activity;
            var viewHolder = activity.LayoutInflater.Inflate(Resource.Layout.Main, this, false);
            view = viewHolder;
            AddView(view);

            //Get and set Views
            videoView = FindViewById<VideoView>(Resource.Id.SampleVideoView);
            playButton = FindViewById<Android.Widget.Button>(Resource.Id.PlayVideoButton);

            //Give some color to the play button, but not important
            playButton.SetBackgroundColor(Android.Graphics.Color.Aqua);
            //uri for a free video
            var uri = Android.Net.Uri.Parse("http://www.androidbegin.com/tutorial/AndroidCommercial.3gp");
            //Set the videoView with our uri, this could also be a local video on device
            videoView.SetVideoURI(uri);
            //Assign click event on our play button to play the video
            playButton.Click += PlayVideo;
        }
Exemplo n.º 9
0
        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();
        }
        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();
            }
        }
Exemplo n.º 11
0
        //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);
            }
        }
Exemplo n.º 13
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);
				};
			}
		}
Exemplo n.º 14
0
        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();
        }
Exemplo n.º 15
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);
            }
		protected override void OnElementChanged (ElementChangedEventArgs<Xamarin.Forms.View> e)
		{
			base.OnElementChanged (e);

			//Get LayoutInflater and inflate from axml
			//Important note, this project utilizes a layout-land folder in the Resources folder
			//Android will use this folder with layout files for Landscape Orientations
			//This is why we don't have to worry about the layout of the play button, it doesn't exist in landscape layout file!!! 
			var activity = Context as Activity; 
			var viewHolder = activity.LayoutInflater.Inflate (Resource.Layout.Main, this, false);
			view = viewHolder;
			AddView (view);

			//Get and set Views
			videoView = FindViewById<VideoView> (Resource.Id.SampleVideoView);
			playButton = FindViewById<Android.Widget.Button> (Resource.Id.PlayVideoButton);

			//Give some color to the play button, but not important
			playButton.SetBackgroundColor (Android.Graphics.Color.Aqua);
			//uri for a free video
			var uri = Android.Net.Uri.Parse ("https://www.dropbox.com/s/hi45psyy0wq9560/PigsInAPolka1943.mp4?dl=1");
			//Set the videoView with our uri, this could also be a local video on device
			videoView.SetVideoURI (uri);
			//Assign click event on our play button to play the video
			playButton.Click += PlayVideo;
		}      
Exemplo n.º 17
0
        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();
        }
        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);
            }
        }
 private void SetSource()
 {
     try
     {
         if (string.IsNullOrWhiteSpace(Element.Source))
         {
             return;
         }
         _prepared = false;
         if (Element.Source.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) ||
             Element.Source.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase))
         {
             _videoView.SetVideoURI(Android.Net.Uri.Parse(Element.Source));
         }
         else
         {
             _videoView.SetVideoPath(Element.Source);
         }
         _videoView.RequestFocus();
         //  _videoView.SetOnPreparedListener(new VideoLoop());
         //_videoView.SetOnPreparedListener(new OnPreparedListener());
     }
     catch (Java.Lang.Exception e)
     {
         System.Diagnostics.Debug.WriteLine(e);
         Element.OnError(e.Message);
     }
 }
Exemplo n.º 20
0
        private void InitComponent()
        {
            try
            {
                var media = new MediaController(this);
                media.Show(5000);

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

                PostVideoView             = FindViewById <VideoView>(Resource.Id.videoView);
                PostVideoView.Completion += PostVideoViewOnCompletion;
                PostVideoView.SetMediaController(media);
                PostVideoView.Prepared += PostVideoViewOnPrepared;
                PostVideoView.CanSeekBackward();
                PostVideoView.CanSeekForward();
                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);
                }

                TabbedMainActivity.GetInstance()?.SetOnWakeLock();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 21
0
        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();
        }
Exemplo n.º 22
0
        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();
        }
Exemplo n.º 23
0
        private void SetSource(String source)
        {
            string uri = source;

            if (!String.IsNullOrWhiteSpace(uri))
            {
                _videoView.SetVideoURI(Android.Net.Uri.Parse(uri));
            }
        }
Exemplo n.º 24
0
        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();
            }
        }
        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();
        }
        void SetVideo()
        {
            atualFrame = 0;
            var move_file  = thisMove.VideoSrc;
            var resourceId = (int)typeof(Resource.Raw).GetField(move_file).GetValue(null);
            var uri        = Android.Net.Uri.Parse("android.resource://" + Application.PackageName + "/" + resourceId.ToString());

            videoView.SetVideoURI(uri);
            seekVideo.Max = 0;
        }
Exemplo n.º 28
0
        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();
        }
Exemplo n.º 29
0
        void SetSource()
        {
            string uri = Element.Source;

            if (!string.IsNullOrWhiteSpace(uri))
            {
                _videoView.SetVideoURI(Android.Net.Uri.Parse(uri));
                _videoView.Start();
            }
        }
Exemplo n.º 30
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);
        }
        private void SetVideoStory(string url)
        {
            try
            {
                StoryImageView.Visibility = StoryImageView.Visibility switch
                {
                    ViewStates.Visible => ViewStates.Gone,
                    _ => StoryImageView.Visibility
                };

                StoryVideoView.Visibility = StoryVideoView.Visibility switch
                {
                    ViewStates.Gone => ViewStates.Visible,
                    _ => StoryVideoView.Visibility
                };

                PlayIconVideo.Visibility = ViewStates.Visible;
                PlayIconVideo.Tag        = "Play";
                PlayIconVideo.SetImageResource(Resource.Drawable.ic_play_arrow);

                switch (StoryVideoView.IsPlaying)
                {
                case true:
                    StoryVideoView.Suspend();
                    break;
                }

                if (url.Contains("http"))
                {
                    StoryVideoView.SetVideoURI(Uri.Parse(url));
                }
                else
                {
                    var file = Uri.FromFile(new File(url));
                    StoryVideoView.SetVideoPath(file?.Path);
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Exemplo n.º 32
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.º 33
0
        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();
        }
Exemplo n.º 34
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View v = inflater.Inflate(Resource.Layout.fragmentVideoLayout, container, false);

            imgf = v.FindViewById <VideoView>(Resource.Id.videoFragment);
            string video = this.Arguments.GetString("VID");

            imgf.SetVideoURI(Android.Net.Uri.Parse(video));
            imgf.Start();
            return(v);
        }
Exemplo n.º 35
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
                }
            }
        }
        public void update()
        {
            Bitmap image = controlBot.API.Camera.GetImage();

            Forward.Click += (o, e) => ForwardPress();
            Video.SetVideoURI(Uri.Parse("rtsp://192.168.0.1/webcam"));
            Backward.Click    += (o, e) => BackwardPress();
            Left.Click        += (o, e) => LeftPress();
            Right.Click       += (o, e) => RightPress();
            rotateLeft.Click  += (o, e) => RotateLeftPress();
            rotateRight.Click += (o, e) => RotateRightPress();
        }
		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 ());
			}
		}
Exemplo n.º 38
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;
            }