Esempio n. 1
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);
        }