EmbedSample.Gtk.cs 1004 B

1234567891011121314151617181920212223242526272829303132333435
  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. "..",
  22. "nodes.mp4"));
  23. _mplayer = Process.Start(new ProcessStartInfo("mplayer",
  24. $"-vo x11 -zoom -loop 0 -wid {control.Handle.ToInt64()} \"{nodes}\"")
  25. {
  26. UseShellExecute = false,
  27. });
  28. return control;
  29. }
  30. }