c# gtk# - mplayer running on a window

Started by Franco57, June 25, 2020, 01:19:08 PM

Previous topic - Next topic

Franco57

I developed a program on a Olinuxino A20 micro using c# gtk# on visual studio for mac. All works fine, but the only thing that goes wrong is when i try to see a video avi using mplayer running on a window. I create a windowforvideo.cs page like the following. Can somehone help me ? The result is only a blank screen.:

using System;
using System.Diagnostics;
using System.Threading;
using Atk ;
using Gtk;
using Gdk;
namespace Eco
{
   public partial class WindowForVideo : Gtk.Window
   {
      private Gtk.Socket socket;
      private int xid;

      public WindowForVideo () :
      base (Gtk.WindowType.Toplevel)
      {
         DrawingArea a = new DrawingArea ();
         a.AddEvents ((int) EventMask.ButtonPressMask);
         a.ButtonPressEvent += delegate(object o, ButtonPressEventArgs args) { this.Destroy();};
         this.Add(a);

                        try
         {
         //video
         this.socket = new Socket();
         this.socket.WidthRequest=1280;
         this.socket.HeightRequest = 1024;
         this.socket.Visible = true;
         this.socket.Realized += new EventHandler(OnVideoWidgetRealized);
         this.Move (0, 0);

      
         this.Build ();
         this.fixed2.Put(socket, 0, 0);
         this.fixed2.Visible=true;

         
         AvviaVideo ();
         }
         catch (Exception exc)
         {
            MessageDialog md = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Close, exc.Message + " - " + this.xid.ToString());
            md.Run();
            md.Destroy();
         }

      }
      protected virtual void OnVideoWidgetRealized (object sender, EventArgs args)
      {   
         this.xid = (int)socket.Id;
      }

      protected void OnEventbox1ButtonPressEvent (object o, Gtk.ButtonPressEventArgs args)
      {
         this.Destroy();
      }
      public void AvviaVideo()
      {   
         
         var paramString = string.Format("-wid {0} -vo x11 -really -quiet -msglevel all=-1 /home/bin/Debug/Filmato_istruzioni_new.avi", xid);
         Process proc = new Process();
         proc.StartInfo.FileName = "/usr/bin/mplayer";
         proc.StartInfo.Arguments = paramString;

         proc.Start();
         proc.WaitForExit();

      }

      protected void OnButton107Clicked (object sender, EventArgs e)
      {
         AvviaVideo ();
      }
   }
}