[Mono-list] Recommended approach for embedding VLC in a Mono app?

thenextman richard at ayudasystems.com
Tue May 18 11:06:16 EDT 2010

I don't think you want to 'ReadToEnd' on the stdout. You only need to
redirect stdout and stderr if you want to do something with what MPlayer
'tells you', but if you do that you should use the asynchronous methods
because ReadToEnd will block.

Here is the method that initialises MPlayer in the WinForms control I am

public override void Initialise()

            _mplayer = new Process();

            _mplayer.StartInfo.CreateNoWindow = true;
            _mplayer.StartInfo.UseShellExecute = false;
            _mplayer.StartInfo.RedirectStandardError = true;
            _mplayer.StartInfo.RedirectStandardInput = true;
            _mplayer.StartInfo.RedirectStandardOutput = true;
            _mplayer.StartInfo.FileName = Provider.Controls.MPlayerPath;
            _mplayer.StartInfo.Arguments =
                string.Format("-slave -quiet -idle -zoom -msglevel
identify=6 -nokeepaspect -fixed-vo -wid {0} ",

            _mplayer.OutputDataReceived += new
            _mplayer.ErrorDataReceived += new

            if (_mplayer.Start() == false)
                _mplayer = null;
                throw new ApplicationException("Unable to start mplayer.");

            _stdIn = _mplayer.StandardInput;
            _stdIn.AutoFlush = true;


You can subscribe the '...DataReceived' events on stdout and stderr, and
then call Begin...ReadLine(). The events will fire when output is received.

Then you can drive the player by writing slave commands to stdin like this:

_stdIn.WriteLine(string.Format("loadfile {0} ",
_stdIn.WriteLine("stop ");


Hope that helps you.
View this message in context: http://mono.1490590.n4.nabble.com/Recommended-approach-for-embedding-VLC-in-a-Mono-app-tp2216492p2221428.html
Sent from the Mono - General mailing list archive at Nabble.com.

More information about the Mono-list mailing list