In case anyone is interested, below is the solution for loading multiple movies using MPlayer and then having them start and run all at the same time. This message posting will at least put this information into the Lazarus forum database so that in the future anyone searching the Web for a solution to the same problem will be directed to this great forum for the answer.
First of all, I did learn how to do multithreading but I also found out that it's not a good idea or even impossible to access and use the components of a form (the first thread) from inside another secondary thread, as taazz said. Thanks so much taazz, BitBangerUSA, kapibara and jc99 (re: previous multimedia posting) for responding. You guys are the greatest.
The unit below, or a variation of it, will load multiple movies into a form and then play them at the same time.
All praise to Lazarus.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
MPlayerCtrl;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
MPlayerControl1: TMPlayerControl;
MPlayerControl2: TMPlayerControl;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
//Procedure below loads one movie and freezes it on the first frame.
procedure TForm1.Button1Click(Sender: TObject);
begin
MPlayerControl1.FileName := 'c:\temp15\bin\film1.mpg';
MPlayerControl1.MPlayerPath:='c:\temp38\mplayer.exe';
MPlayerControl1.play;
MPlayerControl1.SendMPlayerCommand('Pause');
end;
//Procedure below loads the next movie and freezes it on the first frame.
procedure TForm1.Button2Click(Sender: TObject);
begin
MPlayerControl2.FileName := 'c:\temp15\bin\news4.mpg';
MPlayerControl2.MPlayerPath:='c:\temp38\mplayer.exe';
MPlayerControl2.play;
MPlayerControl2.SendMPlayerCommand('Pause');
end;
//Procedure below plays both movies practically at the same time. The
//"Pause" command is a toggle which pauses the movies on its first
//usage and then runs them on the next usage.
procedure TForm1.Button3Click(Sender: TObject);
begin
MPlayerControl1.SendMPlayerCommand('Pause');
MPlayerControl2.SendMPlayerCommand('Pause');
end;
//This procedure stops both movies.
procedure TForm1.Button4Click(Sender: TObject);
begin
MPlayerControl1.stop;
MPlayerControl2.stop;
end;
end.