EmbedSample.Gtk.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #if DESKTOP
  2. using System.IO;
  3. using System.Diagnostics;
  4. using Avalonia.Platform;
  5. namespace NativeEmbedSample;
  6. public partial class EmbedSample
  7. {
  8. private Process _mplayer;
  9. IPlatformHandle CreateLinux(IPlatformHandle parent)
  10. {
  11. if (IsSecond)
  12. {
  13. var chooser = GtkHelper.CreateGtkFileChooser(parent.Handle);
  14. if (chooser != null)
  15. return chooser;
  16. }
  17. var control = base.CreateNativeControlCore(parent);
  18. var nodes = Path.GetFullPath(Path.Combine(typeof(EmbedSample).Assembly.GetModules()[0].FullyQualifiedName,
  19. "..",
  20. "nodes.mp4"));
  21. _mplayer = Process.Start(new ProcessStartInfo("mplayer",
  22. $"-vo x11 -zoom -loop 0 -wid {control.Handle.ToInt64()} \"{nodes}\"")
  23. {
  24. UseShellExecute = false,
  25. });
  26. return control;
  27. }
  28. void DestroyLinux(IPlatformHandle handle)
  29. {
  30. _mplayer?.Kill();
  31. _mplayer = null;
  32. base.DestroyNativeControlCore(handle);
  33. }
  34. }
  35. #endif