EmbedSample.Gtk.cs 1017 B

12345678910111213141516171819202122232425262728293031323334
  1. using System.IO;
  2. using System.Diagnostics;
  3. using Avalonia.Platform;
  4. using Avalonia.Controls.Platform;
  5. using System;
  6. using ControlCatalog.Pages;
  7. namespace ControlCatalog.NetCore;
  8. public class EmbedSampleGtk : INativeDemoControl
  9. {
  10. private Process _mplayer;
  11. public IPlatformHandle CreateControl(bool isSecond, IPlatformHandle parent, Func<IPlatformHandle> createDefault)
  12. {
  13. if (isSecond)
  14. {
  15. var chooser = GtkHelper.CreateGtkFileChooser(parent.Handle);
  16. if (chooser != null)
  17. return chooser;
  18. }
  19. var control = createDefault();
  20. var nodes = Path.GetFullPath(Path.Combine(typeof(EmbedSample).Assembly.GetModules()[0].FullyQualifiedName,
  21. "..", "NativeControls", "Gtk", "nodes.mp4"));
  22. _mplayer = Process.Start(new ProcessStartInfo("mplayer",
  23. $"-vo x11 -zoom -loop 0 -wid {control.Handle.ToInt64()} \"{nodes}\"")
  24. {
  25. UseShellExecute = false,
  26. });
  27. return control;
  28. }
  29. }