Example #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            if (mLibVLC == null)
            {
                mLibVLC      = new LibVLCLibVLC(this);
                mMediaPlayer = new MediaPlayer(mLibVLC);
            }

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button> (Resource.Id.myButton);

            button.Click += delegate {
                button.Text = string.Format("{0} clicks!", count++);

                var m = new MediaLibVLC(mLibVLC, Android.Net.Uri.Parse("http://www.montemagno.com/sample.mp3"));

                // Tell the media player to play the new Media.
                mMediaPlayer.Media = m;

                // Finally, play it!
                mMediaPlayer.Play();
            };
        }
Example #2
0
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

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

            if(mLibVLC == null)
            {
                mLibVLC = new LibVLCLibVLC();
                mMediaPlayer = new MediaPlayer(mLibVLC);
            }

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button> (Resource.Id.myButton);

            button.Click += delegate {
                button.Text = string.Format ("{0} clicks!", count++);

                var m = new MediaLibVLC(mLibVLC, Android.Net.Uri.Parse("http://www.montemagno.com/sample.mp3"));

                // Tell the media player to play the new Media.
                mMediaPlayer.Media = m;

                // Finally, play it!
                mMediaPlayer.Play();
            };
        }
Example #3
0
        public void Release()
        {
            if (IsDisposed)
            {
                return;
            }
            try
            {
                if (_mediaPlayer == null || _mediaPlayer.IsReleased)
                {
                    return;
                }

                _mediaPlayer.Stop();
                _mediaPlayer.VLCVout.DetachViews();
                _mediaPlayer.Release();
                _mediaPlayer.Dispose();
                _libvlc?.Release();
                _libvlc = null;
                Dispose();
                IsDisposed = true;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Example #4
0
 public VlcPlayer(Context context) : base(context)
 {
     LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent,
                                                   ViewGroup.LayoutParams.WrapContent);
     _libvlc      = new LibVLCLibVLC();
     _mediaPlayer = new MediaPlayer(_libvlc);
     _mediaPlayer.VLCVout.SetVideoView(this);
     _mediaPlayer.VLCVout.AttachViews();
     PlayerState = (PlayerState)_mediaPlayer.PlayerState;
     Volume      = 50;
     MonitorPlayerState();
 }
        public async void Play()
        {
            if (mLibVLC == null)
            {
                mLibVLC      = new LibVLCLibVLC(Android.App.Application.Context);
                mMediaPlayer = new MediaPlayer(mLibVLC);
            }
            var streamUri = Preferences.Get("streamUri", string.Empty);

            m = new MediaLibVLC(mLibVLC, Android.Net.Uri.Parse(streamUri));

            // Tell the media player to play the new Media.
            mMediaPlayer.Media = m;

            if (mMediaPlayer.IsPlaying == false)
            {
                // Finally, play it!
                mMediaPlayer.Play();
            }
        }