How to Make Mplayer Frontend lazarus / 9-Editor ---------------------------------------------------------------------- wasis · 2008-03-29 07:02 I am a newbie in lazarus, but I have been using Pascal for a while. But I still am green in programming. I have a question here on how to make Mplayer (well known Media Player in Linux) Frontend such as MPUI, including the seek bar, drag & drop support. Please tell me if some one might know. Thank's Before ---------------------------------------------------------------------- cyber_python · 2008-03-29 12:24 Well, I have never used MPlayer without a GUI but first of all you should check out how the program works form the command line and what are the commands that you would use to perform the tasks that you want your GUI to perform. After you have this done, I believe it should be quite easy to create the corresponding GUI controls and assign their events with methods that will call the MPlayer commands (check out the TProcess component  --  http://wiki.lazarus.freepascal.org/Executing_External_Programs  ) ---------------------------------------------------------------------- wasis · 2008-04-02 07:20 I can run the program from the command line, but the one which I don't know is How to make a button in lazarus and send the command to mplayer. I also want to know on how to embed a movie to My lazarus program. In the other words I want to make a sibling of MPUI or SMplayer. I also don't know on how to open multiple files at the same time. I tried to use the TOPen Dialog but I won't open multiple files. I can select multiple files but not opening them. anyone can help me? ---------------------------------------------------------------------- koko · 2008-04-04 07:55 From man mplayer: Quote  -input file=                       Read commands from the given file.  Mostly useful with a                       FIFO.                       NOTE: When the given file is a FIFO MPlayer  opens  both                       ends  so  you  can do several 'echo "seek 10" > mp_pipe'                       and the pipe will stay valid. So you just create a fifo, point mplayer to it, and write something into it with writeln. I'm also writing a gui to mplayer, source it's very dirty and comments are in italian language, but if you want to take a look, it's here: http://www.gtk-apps.org/content/show.php/MpLaunchpad?content=73644 I also need to find a way to embed mplayer in a gtk2 form, any help here is really appreciated. ---------------------------------------------------------------------- cyber_python · 2008-04-06 15:14 QuoteI also need to find a way to embed mplayer in a gtk2 form, any help here is really appreciated. from the mplayer manual : -wid(alsosee-guiwid)(X11,OpenGLandDirectXonly)[m               This  tells  MPlayer to attach to an existing window.  Useful to               embed MPlayer in a browser (e.g. the plugger extension).  -geometryx[%][:y[%]]or[WxH][+x+y][m               Adjust where the output is on the screen initially.  The x and y               specifications  are  in pixels measured from the top- left of the               screen to the top-left of the image being displayed, however  if               a percentage sign is given after the argument it turns the value               into a percentage of the screen size in that direction.  It also               supports the standard X11 -geometry option format.  If an exter‐               nal window is specified using the -wid option, then the x and  y               coordinates  are  relative  to the top-left corner of the window               rather than the screen.               NOTE: This option is only supported by the x11, xmga, xv,  xvmc,               xvidix, gl, gl2, directx and tdfxfb video output drivers.               EXAMPLE:                  50:40                       Places the window at x=50, y=40.                  50%:50%                       Places the window in the middle of the screen.                  100%                       Places the window at the middle of the right edge of the                       screen. ---------------------------------------------------------------------- koko · 2008-04-06 21:12 Yup, i'm there, but my problem is to find a gtk2 form wid from within my fpc source. ---------------------------------------------------------------------- cyber_python · 2008-04-06 22:13 procedure TForm1.Button1Click(Sender: TObject); var fWindow : TWindow; begin fWindow := GDK_WINDOW_XWINDOW(Pointer(PGtkWidget(Form1.Handle)^.window)); form1.Caption := inttostr(fWindow); end; (if your form is form1 and you place the code above in Button1.click then your form's caption should be your wid) WARNING : The code above only works for GTK widgetset ("Project->Compiler options->LCL widget Type(various) : gtk") I tried it but mplayer dows not show (it must have to do with the form's refreshing or somethng...) ---------------------------------------------------------------------- koko · 2008-04-07 09:34 Thanks! I readed somewhere that someone did it with gtk1 the way you posted (can't remember exactly where), but i need to use it under GTK2, which is not officially supported by lazarus team atm ---------------------------------------------------------------------- da_seeb · 2008-05-11 21:09 I'm currently working on the same issue. Why do I have to use a fifo file as input for mplayer? I tried using TProcess.input the direct way but had no success. Any ideas why? commandstr:='quit'+LineEnding; MPlayerProcess.Input.write(commandstr[1], length(commandstr)); ---------------------------------------------------------------------- moe · 2008-05-15 21:41 Folks, It's been almost half a year since I solved embedding mplayer problem on GTK2. Problem is, that on GTK2 Object's handle points to it's parent's handle instead of self. Solution is easy: Just create an invisible object with canvas (it probably means there is set GTK_DRAWABLE area) like button or scrollbox. And set it's parent property to object where mplayer should play somethig. Sample code below plays some videoclip within ScrollBox. Just replace '/media/data1/klip.avi' with your own. Code: [Select] procedure TMainWindow.RunVideoClick(Sender: TObject); var   fDisplay: PDisplay;   fWindow: Int64;   mplayerproc: TProcess;   DummyButton: TButton;   ScrollBox: TScrollBox; begin   ScrollBox:= TScrollBox.Create(nil);   ScrollBox.Parent:= MainWindow;   ScrollBox.Left:= 0;   ScrollBox.Width:= MainWindow.Width;   ScrollBox.Top:= 0;   ScrollBox.Height:= MainWindow.Height - 100;   DummyButton:= TButton.Create(nil);   DummyButton.Parent:= ScrollBox;;   DummyButton.Visible:= False; //  fDisplay := GDK_WINDOW_XDISPLAY(Pointer(PGtkWidget(scrollbox1.Handle)^.window));   fWindow := GDK_WINDOW_XWINDOW(Pointer(PGtkWidget(DummyButton.Handle)^.window));   mplayerproc:= TProcess.Create(nil);   mplayerproc.Options:= [poWaitOnExit];   mplayerproc.CommandLine:= 'mplayer -slave -quiet -zoom -wid ' + IntToStr(fWindow) + ' /media/data1/klip.avi';   mplayerproc.Execute;   mplayerproc.Free;   DummyButton.Free;   ScrollBox.Free; end; I almost forgot, here comes my uses clause Code: [Select] uses   Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls, Process,  x, xlib, gtk2, gdk2, gdk2x, glib2,   ExtCtrls; ---------------------------------------------------------------------- cyber_python · 2008-05-18 11:48 moe++!!!! ---------------------------------------------------------------------- Troodon · 2009-11-16 05:24 @moe: did you find a way to hide the mplayer console? thanks. ---------------------------------------------------------------------- Leledumbo · 2009-11-16 08:32 Quotedid you find a way to hide the mplayer console?Code: [Select]mplayerproc.Options:= [poWaitOnExit,poNoConsole]; ---------------------------------------------------------------------- theo · 2009-11-16 08:57 http://lazarus-ccr.svn.sourceforge.net/viewvc/lazarus- ccr/components/mplayer/ ---------------------------------------------------------------------- Troodon · 2009-11-16 13:53 Quote from: Leledumbo on November 16, 2009, 09:32:50 amQuotedid you find a way to hide the mplayer console?Code: [Select]mplayerproc.Options:= [poWaitOnExit,poNoConsole]; This doesn't seem to work for me in Lazarus 0.9.29 + FPC 2.3.1 on Win32 (SVN revision 21460) although it may work on Linux (I will try later today). Besides, on Win32, if I use poWaitOnExit then the video plays only partially although the audio plays through the end of the videoclip. ---------------------------------------------------------------------- Troodon · 2009-11-16 13:58 Quote from: theo on November 16, 2009, 09:57:09 amhttp://lazarus- ccr.svn.sourceforge.net/viewvc/lazarus-ccr/components/mplayer/ Thanks, theo. I noticed that component is for gtk2 on Linux. I am trying to embed MPlayer on Windows using the native widgetset. ---------------------------------------------------------------------- davesimplewear · 2009-11-17 04:59 There are 2 mplayer components, the one Theo mentioned as well as mplayer2 which also gives webcam functionality.