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
using:
public override void Initialise()
{
base.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} ",
this._pnlContainer.Handle);
_mplayer.OutputDataReceived += new
DataReceivedEventHandler(_mplayer_OutputDataReceived);
_mplayer.ErrorDataReceived += new
DataReceivedEventHandler(_mplayer_ErrorDataReceived);
if (_mplayer.Start() == false)
{
_mplayer = null;
throw new ApplicationException("Unable to start mplayer.");
}
_stdIn = _mplayer.StandardInput;
_stdIn.AutoFlush = true;
_mplayer.BeginOutputReadLine();
_mplayer.BeginErrorReadLine();
}
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} ",
Paths.GetMediaFilePath(_design)));
_stdIn.WriteLine("stop ");
etc
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.
_______________________________________________
Mono-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list