예제 #1
0
 void Play()
 {
     // Thread.Sleep(1000);
     this.Dispatcher.BeginInvoke(new Action(() => {
         VlcPlayer.Play(new FileInfo(_Path));
     }));
 }
        private void PlayPause_Click(object sender, RoutedEventArgs e)
        {
            VlcPlayer player = Globals.Instance.VlcPlayer;

            if (player == null || File == null)
            {
                return;
            }

            try
            {
                if (player.IsPlaying)
                {
                    player.Pause();
                }
                else
                {
                    if (!player.IsMediaLoaded)
                    {
                        player.LoadFromMemory(File.Data);
                    }

                    player.Play();
                }
            }
            catch (Exception ex)
            {
                App.Window.ShowNotification(NotificationType.Error, ex);
            }
        }
예제 #3
0
        public void PlayClick(object parameter)
        {
            if (_lastMovie is Uri)
            {
                vlcPlayer.LoadMedia((Uri)_lastMovie);
            }
            else if (_lastMovie is string)
            {
                vlcPlayer.LoadMedia((string)_lastMovie);
            }
            else
            {
                return;
            }

            Task.Run(() =>
            {
                vlcPlayer.Play();
            });

            vlcPlayer.LengthChanged += new EventHandler(OnMediaLengthChanged);
            timer.Start();

            player.FullScreenEnabled = true;
            player.PlayEnabled       = false;
            player.PauseEnabled      = true;
            player.StopEnabled       = true;
        }
예제 #4
0
        public void Connect(string url, string username, string password, string libVlcPath = DEFAULT_LIBVLC_PATH, string[] vlcOptions = null)
        {
            if (Player != null && Player.IsLoaded)
            {
                Player.Stop();
            }

            string urlPrefix = "rtsp://" + username + ":" + password + "@";

            _url        = url.Replace("http://", urlPrefix).Replace("https://", urlPrefix);
            _url       += VIDEO_RELATIVE_URL;
            _libVlcPath = libVlcPath ?? DEFAULT_LIBVLC_PATH;
            _vlcOptions = vlcOptions ?? DEFAULT_VLC_OPTIONS;


            Player = new VlcPlayer(DisplayImage.Dispatcher)
            {
                LibVlcPath = _libVlcPath,
                VlcOption  = _vlcOptions
            };
            Player.Initialize(@"..\..\libvlc", new string[] { "-I", "dummy", "--ignore-config", "--no-video-title" });
            Player.VideoSourceChanged += (sender, args) =>
            {
                DisplayImage.Dispatcher.BeginInvoke(new Action(() =>
                {
                    DisplayImage.Source = args.NewVideoSource;
                }));
            };
            Player.LoadMedia(new Uri(_url));
            Player.Play();
        }
예제 #5
0
 public void StartVideo()
 {
     _player.BeginStop(() =>
     {
         _player.LoadMedia(new Uri(_url));
         _player.Play();
     });
 }
예제 #6
0
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            Uri uri = new Uri(path.Text);

            //String pathString = path.Text;

            VlcPlayer.BeginStop((ar) =>
            {
                VlcPlayer.LoadMedia(uri.ToString());
                VlcPlayer.Play();
            });
        }
예제 #7
0
 private void Btn_Click(object sender, RoutedEventArgs e)
 {
     CurrentPlayer.Stop();
     CurrentPlayer.LoadMedia(@"F:\Kugou\Anya Marina - Whatever You Like.mp3");
     CurrentPlayer.Play();
     //if (this.WindowState == WindowState.Maximized)
     //{
     //    this.WindowState = WindowState.Normal;
     //}
     //else
     //{
     //    this.WindowState = WindowState.Maximized;
     //}
 }
 private void OnPlay(object obj, string media)
 {
     try
     {
         if (_videoView.IsPlaying)
         {
             _videoView.Stop();
         }
         _videoView.Play(Android.Net.Uri.Parse(media));
     }
     catch (Exception ex)
     {
         throw;
     }
 }
예제 #9
0
 /// <summary>
 /// Loads a new video.
 /// </summary>
 private async Task LoadNewVideo()
 {
     try
     {
         VlcPlayer.RebuildPlayer();
         await Task.Run(() =>
         {
             VlcPlayer.Stop();
             VlcPlayer.LoadMedia(_imagePathList[_currentImageIndex].FullName);
             VlcPlayer.Play();
             CurrentImage = null;
         });
     }
     catch (Exception ex)
     {
         HandleError(ex);
     }
 }
예제 #10
0
        private void vlcPlayer_Initialized(object sender, EventArgs e)
        {
            VlcPlayer vlcPlayer = sender as VlcPlayer;

            if (null == vlcPlayer || null == vlcPlayer.DataContext as ClassRoom)
            {
                return;
            }
            (vlcPlayer.DataContext as ClassRoom).VlcPlayer = vlcPlayer;

            /*
             * System.Timers.Timer timer = new System.Timers.Timer(50) { AutoReset = false };
             * timer.Elapsed += delegate {
             *  timer.Dispose();
             *  vlcPlayer.LoadMedia((vlcPlayer.DataContext as ClassRoom).VedioAddress);
             *  vlcPlayer.Play();
             *  vlcPlayer.IsMute = true;
             * };
             */
            System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
            timer.Start();
            timer.Interval = 1;
            timer.Tick    += (s, f) =>
            {
                timer.Stop();
                vlcPlayer.LoadMedia((vlcPlayer.DataContext as ClassRoom).VedioAddress);
                vlcPlayer.Play();
            };
            timer.Start();
            System.Windows.Forms.Timer timer1 = new System.Windows.Forms.Timer();
            timer1.Interval = 300;
            timer1.Tick    += (s, f) =>
            {
                timer1.Stop();
                vlcPlayer.IsMute = true;
            };
            timer1.Start();
        }
예제 #11
0
파일: Helper.cs 프로젝트: iorilan/WPF_Vlc
        //public UIElement VideoDisplay()
        //{
        //    if (_player == null)
        //    {
        //        _player = new VlcPlayer()
        //        {
        //            LibVlcPath = _libVlcPath,
        //            VlcOption = _vlcOptions
        //        };
        //    }
        //    return _player;
        //}

        #endregion

        #region --- Methods ---


        public void PlayVideo()
        {
            _player.LoadMedia(new Uri(_url));
            _player.Play();
        }
예제 #12
0
 private void Button_Click_Play(object sender, RoutedEventArgs e)
 {
     VlcPlayer.Play();
 }
예제 #13
0
 public void Play()
 {
     _vlcPlayer.Play();
 }