Recent

Author Topic: Lazarus & mplayer  (Read 13502 times)

alter

  • Full Member
  • ***
  • Posts: 151
    • KSP website
Lazarus & mplayer
« on: December 03, 2009, 02:57:56 pm »
Since I was looking for a class that will work with Qt or Win32 and provide mplayer support and I haven't found one I ported already known one from Gtk2 LCL. The code is available here: http://project.ksplayer.com/browser/ksp/itools/player/cmplayer.pas

TMPlayerControl is not a component (you don't install it on palette). You just put proper unit in uses section and create it as any other class. Before you start using it you should set a few properties. First is MPlayerPath which contains a path to mplayer. Second is WinID which is -wid switch passed to mplayer so player knows which control to paint with video.

Additionally in order to compile unit above (since it is taken from my application) you should do following things:
1. Remove Multilog from uses and remove all references to hLog object.
2. Remove kspfiles from uses and put following function in the code:

Code: [Select]
{$IFDEF WINDOWS}
function IsWin6: boolean;
var
   osVerInfo: TOSVersionInfo;
begin
   Result := false;
   osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo) ;
   if GetVersionEx(osVerInfo) then
   begin
     Result := osVerInfo.dwMajorVersion>=6;
   end;
end; 
{$ENDIF}
Of course this function will require Windows unit in uses (only Windows platform).

What is already done is playing video (tested with Qt interface and Windows Vista) and setting audio volume. What doesn't work is pausing/resuming video. Looping is not tested. Also events, getting movie length (and position) and seek function need to be still implemented.

Troodon

  • Sr. Member
  • ****
  • Posts: 484
Re: Lazarus & mplayer
« Reply #1 on: December 03, 2009, 05:20:03 pm »
Way to go, alter, it's a commendable effort to provide a MPlayer interface for Lazarus/FPC. I have two comments and one question:

- on this end, "-vo" works well in XP and Vista with any of: [direct3d, gl2, gl]; "directx:noaccel" works but no so well

- if mplayer.exe is in the system PATH variable then user doesn't need to provide the full path to it

- did you find a simple way to hide the console window on win32?

Thanks.
« Last Edit: December 03, 2009, 05:23:04 pm by Troodon »
Lazarus/FPC on Linux

alter

  • Full Member
  • ***
  • Posts: 151
    • KSP website
Re: Lazarus & mplayer
« Reply #2 on: December 03, 2009, 08:20:37 pm »
1. I will check it how it works with XP tomorrow
2. Yes, that's true. However if you distribute own mplayer with your application most likely you will want to be sure that mplayer used by your program is the one provided with application. If you are sure that on destination machine there is mplayer (most likely based Unix systems) then there is no need to set path to mplayer.
3. fPlayerProcess.Options:=fPlayerProcess.Options+[poUsePipes,poNoConsole,poStdErrToOutput]; works in my case. poStdErrToOutput here is only optional.

Troodon

  • Sr. Member
  • ****
  • Posts: 484
Re: Lazarus & mplayer
« Reply #3 on: December 03, 2009, 08:53:52 pm »
[poNoConsole]

Hm, interesting... works for me on XP but not on Vista.
Lazarus/FPC on Linux

alter

  • Full Member
  • ***
  • Posts: 151
    • KSP website
Re: Lazarus & mplayer
« Reply #4 on: December 03, 2009, 09:25:21 pm »
[poNoConsole]

Hm, interesting... works for me on XP but not on Vista.
Well I am working on Vista atm and it works. I am using Lazarus 0.9.29 22583 with FPC 2.2.4

Troodon

  • Sr. Member
  • ****
  • Posts: 484
Re: Lazarus & mplayer
« Reply #5 on: December 04, 2009, 04:37:51 am »
It gets worse: the mplayer console window is hidden on one machine running XP, but not on another one, also on XP, and not on Vista. I wonder what I am missing here...
Lazarus/FPC on Linux

 

TinyPortal © 2005-2018