private
void
Button_Click(
object
sender, RoutedEventArgs e)
{
var
window_handle =
new
WindowInteropHelper(
this
).Handle;
var
ffplay =
new
Process
{
StartInfo =
{
FileName = Global.FFPlay,
Arguments =
@"D:\Users\uzivatel\Videos\Simpson.mp4"
,
CreateNoWindow =
true
,
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);
SetParent(ffplay.MainWindowHandle, window_handle);
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);