Example #1
0
 private void CreatePlayer(string streamUrl)
 {
     //var options = new string[] {
     //    "--file-caching=150", "--network-caching=150",
     //    "--clock-jitter=0", "--live-caching=150", "--clock-synchro=0",
     //    "-vvv", "--drop-late-frames", "--skip-frames"
     //};
     //var options = new[] {"-vvv"};
     //_libVlc = new LibVLC(options);
     try
     {
         _libVlc      = new LibVLC();
         _mediaPlayer = new MediaPlayer(_libVlc)
         {
             EnableHardwareDecoding = true
         };
         _videoView = new VideoView(this)
         {
             MediaPlayer = _mediaPlayer
         };
         _videoLayout.AddView(_videoView,
                              new ActionBar.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent));
         var media = new Media(_libVlc, streamUrl, FromType.FromLocation);
         _videoView.MediaPlayer.Play(media);
     }
     catch (Exception exception)
     {
         Console.WriteLine(exception);
     }
 }
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            if (!(holder is IntercomViewHolder viewHolder))
            {
                return;
            }
            var currentIntercom = _intercoms[position];

            viewHolder.NameTextView.Text    = currentIntercom.Name;
            viewHolder.AddressTextView.Text = currentIntercom.Address;
            viewHolder.OpenDoorFab.Click   += (sender, args) => { OpenDoorClick?.Invoke(sender, currentIntercom); };
            var libVlc      = new LibVLC();
            var mediaPlayer = new MediaPlayer(libVlc)
            {
                EnableHardwareDecoding = true
            };
            var videoView = new VideoView(_context)
            {
                MediaPlayer = mediaPlayer
            };

            viewHolder.VideoLayout.AddView(videoView);
            var media = new Media(libVlc, currentIntercom.VideoStream, FromType.FromLocation);

            videoView.MediaPlayer.Play(media);
        }
Example #3
0
        protected override void OnResume()
        {
            base.OnResume();

            _videoView = new VideoView(this);
            AddContentView(_videoView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
            _videoView.MediaPlayer.Play(new Media(_videoView.LibVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation));
        }
Example #4
0
        protected override void OnResume()
        {
            base.OnResume();

            _videoView = new VideoView(this)
            {
                MediaPlayer = _mediaPlayer
            };
            mainLayout = FindViewById <LinearLayout>(Resource.Id.linearLayout1);
            mainLayout.AddView(_videoView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
        }
Example #5
0
        protected override void OnResume()
        {
            base.OnResume();

            _videoView = new VideoView(this);
            AddContentView(_videoView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
            var media         = new Media(_videoView.LibVLC, "http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4", Media.FromType.FromLocation);
            var configuration = new MediaConfiguration();

            configuration.EnableHardwareDecoding();
            media.AddOption(configuration);
            _videoView.MediaPlayer.Play(media);
        }
        protected override void OnResume()
        {
            base.OnResume();
            _mVideoView = new VideoView(this);
            var lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent,
                                                   ViewGroup.LayoutParams.WrapContent);

            _mVideoWrapper.AddView(_mVideoView, lp);
            var media = new Media(_mVideoView.LibVLC, "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov",
                                  Media.FromType.FromLocation);
            var configuration = new MediaConfiguration();

            configuration.EnableHardwareDecoding();
            media.AddOption(configuration);
            _mVideoView.MediaPlayer.Play(media);
        }
Example #7
0
            protected override void OnCreate(Bundle savedInstanceState)
            {
                base.OnCreate(savedInstanceState);
                SetContentView(Resource.Layout.vlc_view);
                string link = Intent.GetStringExtra("link");

                source_link = Intent.GetStringExtra("source_link");
                _videoView  = new VideoView(this);
                AddContentView(_videoView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
                var media         = new Media(_videoView.LibVLC, link, Media.FromType.FromLocation);
                var configuration = new MediaConfiguration();

                configuration.EnableHardwareDecoding();
                media.AddOption(configuration);
                _videoView.MediaPlayer.Play(media);
            }
Example #8
0
        private void Button_Click(object sender, System.EventArgs e)
        {
            //_mediaPlayer.Stop();

            _videoView.MediaPlayer = null;
            mainLayout.RemoveView(_videoView);

            _videoView.Dispose();

            _videoView = new VideoView(this)
            {
                MediaPlayer = _mediaPlayer
            };
            mainLayout.AddView(_videoView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));

            //_videoView.MediaPlayer.Play();
        }
Example #9
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            videoView = FindViewById <LibVLCSharp.Platforms.Android.VideoView>(Resource.Id.videoView1);

            btOpenFile        = FindViewById <Button>(Resource.Id.btOpenFile);
            btOpenFile.Click += btOpenFile_Click;

            btStart        = FindViewById <Button>(Resource.Id.btStart);
            btStart.Click += btStart_Click;

            btPause        = FindViewById <Button>(Resource.Id.btPause);
            btPause.Click += btPause_Click;

            btStop        = FindViewById <Button>(Resource.Id.btStop);
            btStop.Click += btStop_Click;

            btVideoEffects        = FindViewById <Button>(Resource.Id.btVideoEffects);
            btVideoEffects.Click += btVideoEffects_Click;

            sbTimeline = FindViewById <SeekBar>(Resource.Id.sbTimeline);
            sbTimeline.ProgressChanged    += sbTimeline_ProgressChanged;
            sbTimeline.StartTrackingTouch += delegate(object sender, SeekBar.StartTrackingTouchEventArgs args)
            {
                isSeeking = true;
            };
            sbTimeline.StopTrackingTouch += delegate(object sender, SeekBar.StopTrackingTouchEventArgs args)
            {
                isSeeking = false;
            };

            lbPosition = FindViewById <TextView>(Resource.Id.lbPosition);

            pnScreen = FindViewById <GridLayout>(Resource.Id.pnScreen);

            edURL      = FindViewById <EditText>(Resource.Id.edURL);
            edURL.Text = VIDEO_URL;
        }
Example #10
0
        protected override void OnResume()
        {
            base.OnResume();

            Core.Initialize();

            _libVLC      = new LibVLC();
            _mediaPlayer = new MediaPlayer(_libVLC)
            {
                EnableHardwareDecoding = true
            };

            _videoView = new VideoView(this)
            {
                MediaPlayer = _mediaPlayer
            };
            AddContentView(_videoView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
            using var media = new Media(_libVLC, new Uri("http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"));
            _videoView.MediaPlayer.Play(media);
        }
Example #11
0
        protected override void OnResume()
        {
            base.OnResume();

            Core.Initialize();

            _libVLC      = new LibVLC();
            _mediaPlayer = new MediaPlayer(_libVLC)
            {
                EnableHardwareDecoding = true
            };

            _videoView = new VideoView(this)
            {
                MediaPlayer = _mediaPlayer
            };
            AddContentView(_videoView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
            var media = new Media(_libVLC, "https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4", FromType.FromLocation);

            _videoView.MediaPlayer.Play(media);
        }
Example #12
0
        protected override void OnResume()
        {
            base.OnResume();

            Core.Initialize();

            _libVLC      = new LibVLC();
            _mediaPlayer = new MediaPlayer(_libVLC)
            {
                EnableHardwareDecoding = true
            };

            _videoView = new VideoView(this)
            {
                MediaPlayer = _mediaPlayer
            };



            //_videoView = new VideoView(this) { MediaPlayer = _mediaPlayer };
            //AddContentView(_videoView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
            //var media = new Media(_libVLC, "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4", FromType.FromLocation);
            //_videoView.MediaPlayer.Play(media);

            var server  = new Server();
            var stream1 = new MemoryStream();
            var stream2 = new MemoryStream();
            var stream3 = new MemoryStream();
            var assets  = Assets;

            using (var sr = new StreamReader(assets.Open("stream1.mp4")))
            {
                sr.BaseStream.CopyTo(stream1);
            }

            using (var sr = new StreamReader(assets.Open("stream2.mp4")))
            {
                sr.BaseStream.CopyTo(stream2);
            }

            using (var sr = new StreamReader(assets.Open("stream3.mp4")))
            {
                sr.BaseStream.CopyTo(stream3);
            }

            var data   = stream1.ToArray();
            var total  = data.Length;
            var buffer = 10240;
            var i      = 1;

            while (total > 0)
            {
                var skip = (buffer * i);
                var take = (total >= buffer) ? buffer : total;
                total -= take;
                var newData = data.Skip(skip).Take(take).ToArray();

                server.AppendStream(newData);
            }

            //server.AppendStream(stream1);



            while (!server.IsReady)
            {
            }
            _videoView = new VideoView(this)
            {
                MediaPlayer = _mediaPlayer
            };
            AddContentView(_videoView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
            var media = new Media(_libVLC, "http://127.0.0.1:13000", FromType.FromLocation);

            _videoView.MediaPlayer.Play(media);



            //var server = new Server();
            //var libVLC = new LibVLC();

            //server.AppendStream(stream1);

            //while (!server.IsReady)
            //{

            //}

            //var media = new Media(libVLC, "http://127.0.0.1:13000", FromType.FromLocation);
            //////Passa o objeto media para o player
            //var mp = new MediaPlayer(media);
            //mp.Play();



            //server.AppendStream(stream1);
            ////Server server = null;
            ////var thread = new Thread(() =>
            ////{
            ////    server = new Server();
            ////});
            ////thread.Start();

            ////Thread.Sleep(10000);

            ////server.AppendStream(stream1);
            ////server.AppendStream(stream2);
            ////server.AppendStream(stream3);


            //////Cria um objeto media passando a Url do video ou Url do Live Stream
            ////var media = new Media(libVLC, "http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4", FromType.FromLocation);
            ////var media = new Media(libVLC, "http://srv.xtv.group:8880/YuriPeichoto/102030/3166", FromType.FromLocation);

            ////// OU:
            //////Cria um stream lendo o arquivo e cria um objeto media
            //////var stream = new MemoryStream(File.ReadAllBytes(@"C:\xtv\web\stream1.mp4"));
            ////var media = new Media(libVLC, stream);

            //while (!server.IsReady)
            //{

            //}

            //var media = new Media(libVLC, "http://127.0.0.1:13000", FromType.FromLocation);
            //////Passa o objeto media para o player
            //var mp = new MediaPlayer(media);
            //mp.Play();

            //server.AppendStream(stream2);
            //server.AppendStream(stream3);


            //var server = new SocketServer(13000);
            //var remote = new Socket(SocketType.Stream, ProtocolType.Tcp);
            //var remoteEndPoint = new IPEndPoint(IPAddress.Loopback, 13000);



            //var server = new Server(stream1);

            ////if (!File.Exists(Path.Combine(CacheDir.Path, fileName)))
            ////{

            ////    var assets = Assets;
            ////    assets.open
            ////    using (StreamReader sr = new StreamReader(assets.Open(fileName)))
            ////    using (StreamWriter sw = new StreamWriter(Path.Combine(CacheDir.Path, fileName), append: false))
            ////        sw.Write(sr.ReadToEnd());
            ////}
            ////string content;
            ////using (StreamReader sr = new StreamReader(Path.Combine(CacheDir.Path, fileName)))
            ////{
            ////    content = sr.ReadToEnd();
            ////}



            //////var stream1 = new MemoryStream(File.ReadAllBytes(@"C:\xtv\web\stream1.mp4"));
            ////var stream2 = new MemoryStream(File.ReadAllBytes(@"C:\xtv\web\stream2.mp4"));
            ////var stream3 = new MemoryStream(File.ReadAllBytes(@"C:\xtv\web\stream3.mp4"));
            ////var server = new Server();
            ////DisplayAlert("Alert", "You have been alerted", "OK");
            ////var dialog = new AlertDialog.Builder(this);
            ////var alert = dialog.Create();
            ////alert.SetTitle("Title");
            ////alert.SetMessage("Complex Alert");
            ////alert.Show();
            ////var thread = new Thread(() => { Server.Main(stream1); });
            ////thread.Start();



            ////server.AppendStream(stream1);
            ////var stream = new MemoryStream(File.ReadAllBytes(@"C:\xtv\web\stream.mp4"));
            ////"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
            //AddContentView(_videoView, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent));
            ////var media = new Media(_libVLC, stream, null);

            //while (!server.IsReady)
            //{

            //}

            //var media = new Media(_libVLC, "http://0.0.0.0:3000", FromType.FromLocation);
            ////var media = new Media(_libVLC, "http://srv.xtv.group:8880/YuriPeichoto/102030/3166", FromType.FromLocation);
            //_videoView.MediaPlayer.Play(media);

            ////server.AppendStream(stream2);
            ////server.AppendStream(stream3);
        }