Exemplo n.º 1
0
        public LibVlc11xDynamic MakeSecondMediaPlayer(System.Windows.Forms.Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded)
        {
            LibVlc11xDynamic newVlc = new LibVlc11xDynamic();

            newVlc._libVlc       = this._libVlc;
            newVlc._libVlcDLL    = this._libVlcDLL;
            newVlc._ownerControl = ownerControl;
            if (ownerControl != null)
            {
                newVlc._parentForm = ownerControl.FindForm();
            }

            newVlc.LoadLibVlcDynamic();

            newVlc.OnVideoLoaded = onVideoLoaded;
            newVlc.OnVideoEnded  = onVideoEnded;

            if (!string.IsNullOrEmpty(videoFileName))
            {
                IntPtr media = _libvlc_media_new_path(_libVlc, Encoding.UTF8.GetBytes(videoFileName + "\0"));
                newVlc._mediaPlayer = _libvlc_media_player_new_from_media(media);
                _libvlc_media_release(media);

                //  Linux: libvlc_media_player_set_xdrawable (_mediaPlayer, xdrawable);
                //  Mac: libvlc_media_player_set_nsobject (_mediaPlayer, view);
                _libvlc_media_player_set_hwnd(newVlc._mediaPlayer, ownerControl.Handle); // windows

                if (onVideoEnded != null)
                {
                    newVlc._videoEndTimer = new System.Windows.Forms.Timer {
                        Interval = 500
                    };
                    newVlc._videoEndTimer.Tick += VideoEndTimerTick;
                    newVlc._videoEndTimer.Start();
                }

                _libvlc_media_player_play(newVlc._mediaPlayer);
                newVlc._videoLoadedTimer = new System.Windows.Forms.Timer {
                    Interval = 500
                };
                newVlc._videoLoadedTimer.Tick += new EventHandler(newVlc.VideoLoadedTimer_Tick);
                newVlc._videoLoadedTimer.Start();

                newVlc._mouseTimer = new System.Windows.Forms.Timer {
                    Interval = 25
                };
                newVlc._mouseTimer.Tick += newVlc.MouseTimerTick;
                newVlc._mouseTimer.Start();
            }
            return(newVlc);
        }
Exemplo n.º 2
0
        private void HardSubExtract_Shown(object sender, EventArgs e)
        {
            if (openFileDialogVideo.ShowDialog(this) == DialogResult.OK)
            {
                _videoFileName = openFileDialogVideo.FileName;
                tbFileName.Text = openFileDialogVideo.FileName;
                _videoInfo = Utilities.GetVideoInfo(_videoFileName, null);
                var oldPlayer = Configuration.Settings.General.VideoPlayer;
                Configuration.Settings.General.VideoPlayer = "VLC";
                Utilities.InitializeVideoPlayerAndContainer(_videoFileName, _videoInfo, mediaPlayer, VideoLoaded, null);
                Configuration.Settings.General.VideoPlayer = oldPlayer;
                _libVlc = mediaPlayer.VideoPlayer as LibVlc11xDynamic;

                _subtitle = new Subtitle();
            }
            else
            {
                DialogResult = DialogResult.Cancel;
            }
        }
Exemplo n.º 3
0
        public LibVlc11xDynamic MakeSecondMediaPlayer(System.Windows.Forms.Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded)
        {
            LibVlc11xDynamic newVlc = new LibVlc11xDynamic();
            newVlc._libVlc = this._libVlc;
            newVlc._libVlcDLL = this._libVlcDLL;
            newVlc._ownerControl = ownerControl;
            if (ownerControl != null)
                newVlc._parentForm = ownerControl.FindForm();

            newVlc.LoadLibVlcDynamic();

            newVlc.OnVideoLoaded = onVideoLoaded;
            newVlc.OnVideoEnded = onVideoEnded;

            if (!string.IsNullOrEmpty(videoFileName))
            {
                IntPtr media = _libvlc_media_new_path(_libVlc, Encoding.UTF8.GetBytes(videoFileName + "\0"));
                newVlc._mediaPlayer = _libvlc_media_player_new_from_media(media);
                _libvlc_media_release(media);

                //  Linux: libvlc_media_player_set_xdrawable (_mediaPlayer, xdrawable);
                //  Mac: libvlc_media_player_set_nsobject (_mediaPlayer, view);
                _libvlc_media_player_set_hwnd(newVlc._mediaPlayer, ownerControl.Handle); // windows

                if (onVideoEnded != null)
                {
                    newVlc._videoEndTimer = new System.Windows.Forms.Timer { Interval = 500 };
                    newVlc._videoEndTimer.Tick += VideoEndTimerTick;
                    newVlc._videoEndTimer.Start();
                }

                _libvlc_media_player_play(newVlc._mediaPlayer);
                newVlc._videoLoadedTimer = new System.Windows.Forms.Timer { Interval = 500 };
                newVlc._videoLoadedTimer.Tick += new EventHandler(newVlc.VideoLoadedTimer_Tick);
                newVlc._videoLoadedTimer.Start();

                newVlc._mouseTimer = new System.Windows.Forms.Timer { Interval = 25 };
                newVlc._mouseTimer.Tick += newVlc.MouseTimerTick;
                newVlc._mouseTimer.Start();
            }
            return newVlc;
        }