예제 #1
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;
        }
예제 #2
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();
        }
        public void LoadMedia(string filepath, string[] option = null)
        {
            if (option == null)
            {
                _vlcPlayer.LoadMedia(filepath);
            }
            else
            {
                _vlcPlayer.LoadMediaWithOptions(filepath, option);
            }

            // InitializeComponent();
            HookUpEvents();

            Play();
        }
예제 #4
0
 public void StartVideo()
 {
     _player.BeginStop(() =>
     {
         _player.LoadMedia(new Uri(_url));
         _player.Play();
     });
 }
예제 #5
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();
            });
        }
예제 #6
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;
     //}
 }
예제 #7
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);
     }
 }
예제 #8
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();
        }
예제 #9
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();
        }
예제 #10
0
        public MediaPlayer(string filePath)
        {
            InitializeComponent();

            VlcPlayer.LoadMedia(filePath);
        }