è possibile avviare il processo di ffplay
e poi PInvoke SetParent
per posizionare la finestra del lettore all'interno del modulo e MoveWindow
per posizionarlo.
Per fare ciò è necessario definire quanto segue.
[DllImport("user32.dll", SetLastError = true)]
private static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
[DllImport("user32.dll")]
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
Quindi è possibile utilizzare i due metodi nativi in questo modo.
// start ffplay
var ffplay = new Process
{
StartInfo =
{
FileName = "ffplay",
Arguments = "tcp://192.168.1.1:5555",
// hides the command window
CreateNoWindow = true,
// redirect input, output, and error streams..
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false
}
};
ffplay.EnableRaisingEvents = true;
ffplay.OutputDataReceived += (o, e) => Debug.WriteLine(e.Data ?? "NULL", "ffplay");
ffplay.ErrorDataReceived += (o, e) => Debug.WriteLine(e.Data ?? "NULL", "ffplay");
ffplay.Exited += (o, e) => Debug.WriteLine("Exited", "ffplay");
ffplay.Start();
Thread.Sleep(200); // you need to wait/check the process started, then...
// child, new parent
// make 'this' the parent of ffmpeg (presuming you are in scope of a Form or Control)
SetParent(ffplay.MainWindowHandle, this.Handle);
// window, x, y, width, height, repaint
// move the ffplayer window to the top-left corner and set the size to 320x280
MoveWindow(ffplay.MainWindowHandle, 0, 0, 320, 280, true);
L'output standard del processo ffplay
, il testo di solito si vede nella finestra di comando viene gestita tramite ErrorDataReceived
. L'impostazione di -loglevel
su qualcosa come fatal
negli argomenti passati a ffplay consente di ridurre la quantità di eventi generati e consente di gestire solo errori reali.
Quale codice avete finora per fare questo ..? – MethodMan
controlla questo link e guarda la documentazione che può o non può aiutare .. http://gstreamer.freedesktop.org/ – MethodMan
http://dronecontroller.codeplex.com/ – MethodMan