Multimedia Programming

From Lazarus wiki
Jump to navigationJump to search

Starting a player application

Once you know the command line and parameters you can use TProcessUTF8 to start the player:

<Delphi> uses

 Classes, ..., LCLProc, UTF8Process;

...

implementation

procedure TMainForm.Button1Click(Sender: TObject); var

 Player: TProcessUTF8;

begin

 Player:=TProcessUTF8.Create(nil);
 try
   Player.CommandLine:=PathToPlayer+' '+ParametersAndMediaFile;
   Player.Execute;
 finally
   Player.Free;
 end;

end; </Delphi>

For example to start under Linux the mplayer to play a video use:

<Delphi> uses

 Classes, ..., FileUtil, LCLProc, UTF8Process;

...

implementation

procedure TMainForm.Button1Click(Sender: TObject); var

 Player: TProcessUTF8;
 Filename: String;
 PlayerPath: String;
 PlayerParams: String;

begin

 Filename:='/home/username/video.mpg';
 PlayerPath:=FindDefaultExecutablePath('mplayer');
 PlayerParams:='"'+Filename+'"';
 Player:=TProcessUTF8.Create(nil);
 try
   Player.CommandLine:=PlayerPath+' '+PlayerParams;
   Player.Execute;
 finally
   Player.Free;
 end;

end; </Delphi>

VFW - Video for Windows

Capturing and playing video streams from TV cards and webcams under Windows the VFW API can be used with SysRec.

MPlayer for Linux gtk2/X

mplayer is an open source and free movie player. There is a LCL control embedding the mplayer, so you can built your own movie players or just play a video in your application. You can download it here:

svn co https://lazarus-ccr.svn.sourceforge.net/svnroot/lazarus-ccr/components/mplayer mplayer