Beispiel #1
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.KeyPreview = true;

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

            this._play = LibMPlayerCommon.PlayerFactory.Get(panelVideo.Handle.ToInt64(), MediaPlayer.Properties.Settings.Default.MPlayerPath);
            //this._play = new MPlayer(panelVideo.Handle.ToInt64(), 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());
            }
        }
Beispiel #2
0
        /// <summary>
        /// Create a new instance of mplayer class.
        /// </summary>
        /// <param name="wid">Window ID that mplayer should attach itself</param>
        /// <param name="backend">The video output backend that mplayer will use.</param>
        /// <param name="mplayerPath">The full filepath to mplayer.exe.  If mplayerPath is left empty it will search for mplayer.exe in
        /// "current directory\backend\mplayer.exe" on windows and mplayer in the path on linux.</param>
        /// <param name="loadMplayer">If true mplayer will immediately be loaded and you should not attempt to
        /// play any files until MplayerRunning is true.</param>
        public MPlayer(int wid, MplayerBackends backend, string mplayerPath, bool loadMplayer)
        {
            this._wid            = wid;
            this._fullscreen     = false;
            this.MplayerRunning  = false;
            this._mplayerBackend = backend;
            this._mplayerPath    = mplayerPath;
            this.CurrentStatus   = MediaStatus.Stopped;

            this._backendProgram = new BackendPrograms(mplayerPath);

            MediaPlayer = new System.Diagnostics.Process();

            // This timer will send an event every second with the current video postion when video
            // is in play mode.
            this._currentPostionTimer          = new System.Timers.Timer(1000);
            this._currentPostionTimer.Elapsed += new ElapsedEventHandler(_currentPostionTimer_Elapsed);
            this._currentPostionTimer.Enabled  = true;

            if (loadMplayer)
            {
                Action caller = new Action(InitializeMplayer);
                caller.BeginInvoke(null, null);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Create a new instance of mplayer class.
        /// </summary>
        /// <param name="wid">Window ID that mplayer should attach itself</param>
        /// <param name="backend">The video output backend that mplayer will use.</param>
        /// <param name="mplayerPath">The full filepath to mplayer.exe.  If mplayerPath is left empty it will search for mplayer.exe in
        /// "current directory\backend\mplayer.exe" on windows and mplayer in the path on linux.</param>
        /// <param name="loadMplayer">If true mplayer will immediately be loaded and you should not attempt to
        /// play any files until MplayerRunning is true.</param>
        /// <param name="positionUpdateInterval">Interval of periodical position updates</param>
        /// <param name="consoleArguments">Specify custom console arguments here; default "-slave -quiet -idle -v -ontop" ( do not set -vo and -wid ) </param>
        public MPlayer(int wid, MplayerBackends backend, string mplayerPath, bool loadMplayer, TimeSpan positionUpdateInterval, string consoleArguments = "-slave -quiet -idle -v -ontop")
        {
            this._wid            = wid;
            this._fullscreen     = false;
            this.MplayerRunning  = false;
            this._mplayerBackend = backend;
            this._mplayerPath    = mplayerPath;
            this.CurrentStatus   = MediaStatus.Stopped;

            this.consoleArguments = consoleArguments;

            this._backendProgram = new BackendPrograms(mplayerPath);

            MediaPlayer = new System.Diagnostics.Process();

            // This timer will send an event every second with the current video postion when video
            // is in play mode.
            this._currentPostionTimer          = new System.Timers.Timer(positionUpdateInterval.TotalMilliseconds);
            this._currentPostionTimer.Elapsed += new ElapsedEventHandler(_currentPostionTimer_Elapsed);
            this._currentPostionTimer.Enabled  = false;

            if (loadMplayer)
            {
                Action caller = new Action(InitializeMplayer);
                caller.BeginInvoke(null, null);
            }
        }
Beispiel #4
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());
            }

        }
Beispiel #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());
            }

        }
Beispiel #6
0
        /// <summary>
        /// Create a new instance of mplayer class.
        /// </summary>
        /// <param name="wid">Window ID that mplayer should attach itself</param>
        /// <param name="backend">The video output backend that mplayer will use.</param>
        /// <param name="mplayerPath">The full filepath to mplayer.exe.  If mplayerPath is left empty it will search for mplayer.exe in 
        /// "current directory\backend\mplayer.exe" on windows and mplayer in the path on linux.</param>
        public MPlayer(int wid, MplayerBackends backend, string mplayerPath)
        {
            this._wid = wid;
            this._fullscreen = false;
            this.MplayerRunning = false;
            this._mplayerBackend = backend;
            this._mplayerPath = mplayerPath;
            this.CurrentStatus = MediaStatus.Stopped;

            this._backendProgram = new BackendPrograms(mplayerPath);

            MediaPlayer = new System.Diagnostics.Process();

            // This timer will send an event every second with the current video postion when video
            // is in play mode.
            this._currentPostionTimer = new System.Timers.Timer(1000);
            this._currentPostionTimer.Elapsed += new ElapsedEventHandler(_currentPostionTimer_Elapsed);
            this._currentPostionTimer.Enabled = true;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="mplayerPath">If mplayerPath is left empty it will search for mplayer.exe in 
        /// "current directory\backend\mplayer.exe" on windows and mplayer in the path on linux.</param>
        public Discover(string filePath, string mplayerPath)
        {
            /*
             Reads the values of the video (width, heigth, fps...) and stores them
             into file_values.

             Returns (False,AUDIO) if the file is not a video (with AUDIO the number
             of audio tracks)

             Returns (True,0) if the file is a right video file
             */

            BackendPrograms mplayerLocation = new BackendPrograms(mplayerPath);

            int audio = 0;
            int video = 0;
            int nframes = 1;

            int minimum_audio = 10000;
            _AudioList = new List<int>();
            _AudioTracks = new List<AudioTrackInfo>();
            _SubtitleList = new List<SubtitlesInfo>();
            // if CHECK_AUDIO is TRUE, we just check if it's an audio file

            //if check_audio:
            //    nframes=0
            //else:
            //    nframes=1

            System.Diagnostics.Process handle = new System.Diagnostics.Process();

            handle.StartInfo.UseShellExecute = false;
            handle.StartInfo.CreateNoWindow = true;
            handle.StartInfo.RedirectStandardOutput = true;
            handle.StartInfo.RedirectStandardError = true;

            handle.StartInfo.FileName = mplayerLocation.MPlayer;
            handle.StartInfo.Arguments = string.Format("-loop 1 -identify -ao null -vo null -frames 0 {0} \"{1}\"", nframes.ToString(), filePath);
            handle.Start();
            string line = "";
            StringReader strReader = new StringReader(handle.StandardOutput.ReadToEnd());

            while ((line = strReader.ReadLine()) != null)
            //while (handle.HasExited == false)
            {

                if (line.Trim() == "")
                {
                    continue;
                }
                int position = line.IndexOf("ID_");
                if (position == -1)
                {
                    continue;
                }
                line = line.Substring(position);
                if (line.StartsWith("ID_VIDEO_BITRATE"))
                {
                    _VideoBitrate = Globals.IntParse(line.Substring(17)) / 1000; // kilobits per second
                }
                else if (line.StartsWith("ID_VIDEO_WIDTH"))
                {
                    _Width = Globals.IntParse(line.Substring(15));
                }
                else if (line.StartsWith("ID_VIDEO_HEIGHT"))
                {
                    _Height = Globals.IntParse(line.Substring(16));
                }
                else if (line.StartsWith("ID_VIDEO_ASPECT"))
                {
                    _AspectRatio = Globals.FloatParse(line.Substring(16));
                }
                else if (line.StartsWith("ID_VIDEO_FPS"))
                {
                    _fps = (int)Globals.FloatParse(line.Substring(13));
                }
                else if (line.StartsWith("ID_AUDIO_BITRATE"))
                {
                    _AudioBitrate = Globals.IntParse(line.Substring(17)) / 1000; // kilobits per second
                }
                else if (line.StartsWith("ID_AUDIO_RATE"))
                {
                    _AudioRate = Globals.IntParse(line.Substring(14));
                }
                else if (line.StartsWith("ID_LENGTH"))
                {
                    _Length = (int)Globals.FloatParse(line.Substring(10));
                }
                else if (line.StartsWith("ID_VIDEO_ID"))
                {
                    video += 1;
                    _Video = true;
                }
                else if (line.StartsWith("ID_AUDIO_ID"))
                {
                    audio += 1;
                    _Audio = true;
                    int audio_track = Globals.IntParse(line.Substring(12));
                    if (minimum_audio > audio_track)
                    {
                        minimum_audio = audio_track;
                    }
                    _AudioList.Add(audio_track);

                    AudioTrackInfo info = new AudioTrackInfo();
                    info.ID = audio_track;
                    _AudioTracks.Add(info);

                }
                else if (line.StartsWith("ID_AID_") && line.Substring(9, 4) == "LANG")
                {
                    if (_AudioTracks.Count > 0)
                    {
                        string value = line.Substring(14);

                        _AudioTracks[_AudioTracks.Count - 1].Language = value;
                    }
                }
                else if (line.StartsWith("ID_AID_") && line.Substring(9, 4) == "NAME")
                {
                    if (_AudioTracks.Count > 0)
                    {
                        string value = line.Substring(14);

                        _AudioTracks[_AudioTracks.Count-1].Name = value;
                    }
                }
                else if (line.StartsWith("ID_SUBTITLE_ID"))
                {
                    int value = Globals.IntParse(line.Substring(15));

                    SubtitlesInfo info = new SubtitlesInfo();
                    info.ID = value;
                    _SubtitleList.Add(info);

                }
                else if (line.StartsWith("ID_SID_") && line.Substring(9, 4) == "LANG")
                {
                    if (_SubtitleList.Count > 0)
                    {
                        string value = line.Substring(14);

                        _SubtitleList[_SubtitleList.Count - 1].Language = value;
                    }
                }
                else if (line.StartsWith("ID_SID_") && line.Substring(9, 4) == "NAME")
                {
                    if (_SubtitleList.Count > 0)
                    {
                        string value = line.Substring(14);

                        _SubtitleList[_SubtitleList.Count - 1].Name = value;
                    }
                }
            }

            handle.WaitForExit();
            handle.Close();

            if (_AspectRatio == 0.0)
            {
                _AspectRatio = ((float)_Width / (float)_Height);
                if (_AspectRatio <= 1.5)
                {
                    _AspectRatio = (ScreenAspectRatio.FourThree);
                }
            }
        }
Beispiel #8
0
        public void Execute()
        {
            /*
             * Reads the values of the video (width, heigth, fps...) and stores them
             * into file_values.
             *
             * Returns (False,AUDIO) if the file is not a video (with AUDIO the number
             * of audio tracks)
             *
             * Returns (True,0) if the file is a right video file
             */

            BackendPrograms mplayerLocation = new BackendPrograms(mplayerPath);

            int audio   = 0;
            int video   = 0;
            int nframes = 1;

            int minimum_audio = 10000;

            _AudioList    = new List <int> ();
            _AudioTracks  = new List <AudioTrackInfo> ();
            _SubtitleList = new List <SubtitlesInfo> ();
            // if CHECK_AUDIO is TRUE, we just check if it's an audio file

            //if check_audio:
            //    nframes=0
            //else:
            //    nframes=1

            using (var handle = new System.Diagnostics.Process()) {
                handle.StartInfo.UseShellExecute        = false;
                handle.StartInfo.CreateNoWindow         = true;
                handle.StartInfo.RedirectStandardOutput = true;
                handle.StartInfo.RedirectStandardError  = true;

                handle.StartInfo.FileName  = mplayerLocation.MPlayer;
                handle.StartInfo.Arguments = string.Format("-loop 1 -identify -ao null -vo null -frames 0 {0} \"{1}\"", nframes.ToString(), filePath);
                handle.Start();
                string       line      = "";
                StringReader strReader = new StringReader(handle.StandardOutput.ReadToEnd());

                while ((line = strReader.ReadLine()) != null)                   //while (handle.HasExited == false)

                {
                    if (line.Trim() == "")
                    {
                        continue;
                    }
                    int position = line.IndexOf("ID_");
                    if (position == -1)
                    {
                        continue;
                    }
                    line = line.Substring(position);
                    if (line.StartsWith("ID_VIDEO_BITRATE"))
                    {
                        _VideoBitrate = Globals.IntParse(line.Substring(17)) / 1000;   // kilobits per second
                    }
                    else if (line.StartsWith("ID_VIDEO_WIDTH"))
                    {
                        _Width = Globals.IntParse(line.Substring(15));
                    }
                    else if (line.StartsWith("ID_VIDEO_HEIGHT"))
                    {
                        _Height = Globals.IntParse(line.Substring(16));
                    }
                    else if (line.StartsWith("ID_VIDEO_ASPECT"))
                    {
                        _AspectRatio = Globals.FloatParse(line.Substring(16));
                    }
                    else if (line.StartsWith("ID_VIDEO_FPS"))
                    {
                        _fps = (int)Globals.FloatParse(line.Substring(13));
                    }
                    else if (line.StartsWith("ID_AUDIO_BITRATE"))
                    {
                        _AudioBitrate = Globals.IntParse(line.Substring(17)) / 1000;   // kilobits per second
                    }
                    else if (line.StartsWith("ID_AUDIO_RATE"))
                    {
                        _AudioRate = Globals.IntParse(line.Substring(14));
                    }
                    else if (line.StartsWith("ID_LENGTH"))
                    {
                        _Length = (int)Globals.FloatParse(line.Substring(10));
                    }
                    else if (line.StartsWith("ID_VIDEO_ID"))
                    {
                        video += 1;
                        _Video = true;
                    }
                    else if (line.StartsWith("ID_AUDIO_ID"))
                    {
                        audio += 1;
                        _Audio = true;
                        int audio_track = Globals.IntParse(line.Substring(12));
                        if (minimum_audio > audio_track)
                        {
                            minimum_audio = audio_track;
                        }
                        _AudioList.Add(audio_track);

                        AudioTrackInfo info = new AudioTrackInfo();
                        info.ID = audio_track;
                        _AudioTracks.Add(info);
                    }
                    else if (line.StartsWith("ID_AID_") && line.Substring(9, 4) == "LANG")
                    {
                        if (_AudioTracks.Count > 0)
                        {
                            string value = line.Substring(14);

                            _AudioTracks [_AudioTracks.Count - 1].Language = value;
                        }
                    }
                    else if (line.StartsWith("ID_AID_") && line.Substring(9, 4) == "NAME")
                    {
                        if (_AudioTracks.Count > 0)
                        {
                            string value = line.Substring(14);

                            _AudioTracks [_AudioTracks.Count - 1].Name = value;
                        }
                    }
                    else if (line.StartsWith("ID_SUBTITLE_ID"))
                    {
                        int value = Globals.IntParse(line.Substring(15));

                        SubtitlesInfo info = new SubtitlesInfo();
                        info.ID = value;
                        _SubtitleList.Add(info);
                    }
                    else if (line.StartsWith("ID_SID_") && line.Substring(9, 4) == "LANG")
                    {
                        if (_SubtitleList.Count > 0)
                        {
                            string value = line.Substring(14);

                            _SubtitleList [_SubtitleList.Count - 1].Language = value;
                        }
                    }
                    else if (line.StartsWith("ID_SID_") && line.Substring(9, 4) == "NAME")
                    {
                        if (_SubtitleList.Count > 0)
                        {
                            string value = line.Substring(14);

                            _SubtitleList [_SubtitleList.Count - 1].Name = value;
                        }
                    }
                }

                handle.WaitForExit();
                handle.Close();
            }
            if (_AspectRatio == 0.0)
            {
                _AspectRatio = ((float)_Width / (float)_Height);
                if (_AspectRatio <= 1.5)
                {
                    _AspectRatio = (ScreenAspectRatio.FourThree);
                }
            }
        }
Beispiel #9
0
 public Mencoder(string mencoderPath)
 {
     _backendProgram = new BackendPrograms("", mencoderPath);
 }
Beispiel #10
0
 public Mencoder()
 {
     _backendProgram = new BackendPrograms();
 }
 public SlideShow(string mencoderPath)
 {
     _backend = new BackendPrograms("", mencoderPath);
     _workingDirectory = System.IO.Path.Combine(Globals.MajorSilenceMEncoderLocalAppDataDirectory, "SlideShow");
     _imageDirectory = System.IO.Path.Combine(_workingDirectory, "Images");
     _videoDirectory = System.IO.Path.Combine(_workingDirectory, "Videos");
 }
Beispiel #12
0
        public Mencoder(string mencoderPath)
        {

            _backendProgram = new BackendPrograms("", mencoderPath);
        }
Beispiel #13
0
        public Mencoder()
        {

            _backendProgram = new BackendPrograms();
        }