Esempio n. 1
0
        public Player()
        {
            //var handle = (int) Process.GetCurrentProcess().MainWindowHandle;

            _mPlayer = new LibMPlayerCommon.MPlayer(0, MplayerBackends.SDL,
                                                    @"mplayer");
            _mPlayer.CurrentPosition += OnCurrentPosition;
            // _mPlayer.VideoExited += OnVideoExited;
            _mPlayer.MplayerOutput += OnVideoExited;


            RefreshFiles();
            SaveProgress();
        }
        protected void OnButtonPlayClicked(object sender, System.EventArgs e)
        {
            if (_play != null)
            {
                _play.Stop();
            }

            int handle = (int)this.drawingareaVideo.Handle;

            if (System.IO.File.Exists(VideoPath) == false)
            {
                throw new System.IO.FileNotFoundException("File not found", VideoPath);
            }

            _play = new MPlayer(handle, MplayerBackends.GL, MPlayerPath);
            _play.Play(VideoPath);
        }
        private void buttonPlay_Click(object sender, EventArgs e)
        {
            if (_play != null)
            {
                _play.Stop();
            }

            int handle = (int)this.panelVideo.Handle;

            if (System.IO.File.Exists(MPlayerPath) == false)
            {
                throw new System.IO.FileNotFoundException("File not found", MPlayerPath);
            }

            if (System.IO.File.Exists(VideoPath) == false && VideoPath.StartsWith("http") == false)
            {
                throw new System.IO.FileNotFoundException("File not found", VideoPath);
            }

            _play = new MPlayer(handle, MplayerBackends.Direct3D, MPlayerPath);
            _play.Play(VideoPath);
        }
        private void buttonPlay_Click(object sender, RoutedEventArgs e)
        {
            if (_play != null)
            {
                _play.Stop();
            }

            int handle = (int)this.windowsFormsHost1.Handle;

            if (System.IO.File.Exists(MPlayerPath) == false)
            {
                throw new System.IO.FileNotFoundException("File not found", MPlayerPath);
            }

            if (System.IO.File.Exists(VideoPath) == false)
            {
                throw new System.IO.FileNotFoundException("File not found", VideoPath);
            }

            _play = new MPlayer(handle, MplayerBackends.Direct3D, MPlayerPath);
            _play.Play(VideoPath);

        }
Esempio n. 5
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            LibMPlayerCommon.BackendPrograms b = new LibMPlayerCommon.BackendPrograms();
            if (System.IO.File.Exists(MediaPlayer.Properties.Settings.Default.MPlayerPath) == false
                && System.IO.File.Exists(b.MPlayer) == false && BackendPrograms.OSPlatform() == "windows")
            {
                MessageBox.Show("Cannot find mplayer.  Loading properties form to select.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnPlayerProperties_Click(sender, e);
            }

            MplayerBackends backend;
            System.PlatformID runningPlatform = System.Environment.OSVersion.Platform;
            if (runningPlatform == System.PlatformID.Unix)
            {
                backend = MplayerBackends.GL2;
            }
            else if (runningPlatform == PlatformID.MacOSX)
            {
                backend = MplayerBackends.OpenGL;
            }
            else
            {
                backend = MplayerBackends.Direct3D;
            }

            this._play = new MPlayer(panelVideo.Handle.ToInt32(), backend, MediaPlayer.Properties.Settings.Default.MPlayerPath);
            this._play.VideoExited += new MplayerEventHandler(play_VideoExited);
            this._play.CurrentPosition += new MplayerEventHandler(_play_CurrentPosition);

            // Set fullscreen
            if (_fullscreen == true && (this.WindowState != FormWindowState.Maximized))
            {
                this.ToggleFormFullScreen();
            }

            // start playing mmediately
            if (_playNow == true && this._filePath != "")
            {
                btnPlay_Click(new object(), new EventArgs());
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Creates the wrapper for the mplayer library.
        /// </summary>
        /// <param name="handle">pointer to the panel where the video needs to be displayed</param>
        public MediaPlayer(IntPtr handle)
            : base(null)
        {
            //we only initialize mplayer once.
            if (null == _play)
            {
                this._handle = handle;

                MplayerBackends backend;
                System.PlatformID runningPlatform = System.Environment.OSVersion.Platform;
                if (runningPlatform == System.PlatformID.Unix)
                {
                    backend = MplayerBackends.GL2;
                }
                else if (runningPlatform == PlatformID.MacOSX)
                {
                    backend = MplayerBackends.OpenGL;
                }
                else
                {
                    //The Direct3D backend in the version of mplayer I'm using, has issues on 64bit windows
                    backend = MplayerBackends.DirectX;
                }

                _play = new MPlayer((int)handle, backend);
                _play.Init();
            }

            //configure the timer that will check the current position twice every second, until the end of time.
            _playPositionTimer = new Timer();
            _playPositionTimer.Interval = PLAY_POSITION_UPDATE_INTERVAL_MILLISECONDS;
            _playPositionTimer.Elapsed += new ElapsedEventHandler(_playPositionTimer_Elapsed);
        }