Dobrý den, zkoušel jsem si ve WPF udělat jednoduchý přehrávač videa s využitím frameworku FFPlay. FFPlay se však i přes nastavení otevírá v samostatném okně, které nejde skrýt, ani přesunout a zmenšit prostřednictvím user32.dll funkcí. Měli byste nějaký tip? Děkuji
private void Button_Click(object sender, RoutedEventArgs e)
{
var window_handle = new WindowInteropHelper(this).Handle;
// start ffplay
var ffplay = new Process
{
StartInfo =
{
FileName = Global.FFPlay,
Arguments = @"D:\Users\uzivatel\Videos\Simpson.mp4",
// hides the command window
CreateNoWindow = true,
// redirect input, output, and error streams..
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false
}
};
ffplay.EnableRaisingEvents = true;
ffplay.OutputDataReceived += Ffplay_OutputDataReceived;
ffplay.ErrorDataReceived += Ffplay_OutputDataReceived;
ffplay.Exited += (o, a) => Console.WriteLine("exited");
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, window_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, (int)mediaElement.Width, (int)mediaElement.Height, false);
}
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
private static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
|