怎么样实现播放器的多窗口同时播放(0分)

  • 主题发起人 主题发起人 艰苦
  • 开始时间 开始时间

艰苦

Unregistered / Unconfirmed
GUEST, unregistred user!
]!!!怎么样实现播放器的多窗口同时播放!!!
功能:要实现播放器的多窗口播放!

问题:播放器form1运行时,当点击button1激活窗口form2,可是form2并没有和form1同时播放,并且没有图象显示!希望大家可以帮助!!!

请愿意的朋友赐教!谢谢~~!
代码如下:

【form1 单元代码】

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, MPlayer, ExtCtrls;

type
TForm1 = class(TForm)
Panel1: TPanel;
MediaPlayer1: TMediaPlayer;
Panel2: TPanel;
Button1: TButton;
Button2: TButton;
OpenDialog1: TOpenDialog;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation
uses unit2;
{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin

form1.MediaPlayer1.Visible:=true;
form1.MediaPlayer1.Display:=form1.Panel2;
form1.Button1.Enabled:=true;
form1.Button2.Enabled:=true;

end;


procedure TForm1.Button1Click(Sender: TObject);
begin

form2.Show;

end;


procedure TForm1.Button2Click(Sender: TObject);
begin

if form1.OpenDialog1.Execute then

begin

form1.MediaPlayer1.FileName:=form1.OpenDialog1.FileName;
form1.MediaPlayer1.Open;
mediaplayer1.DisplayRect:=panel2.ClientRect;
end;


end;

procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin

form1.MediaPlayer1.Stop;
form1.MediaPlayer1.Close;
end;


end.






【form2 单元代码】

unit Unit2;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, MPlayer;

type
TForm2 = class(TForm)
Panel1: TPanel;
MediaPlayer1: TMediaPlayer;
procedure FormCreate(Sender: TObject);

private
{ Private declarations }
public
{ Public declarations }
end;


var
Form2: TForm2;

implementation
uses unit1;
{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
begin

form2.Panel1.Align:=alClient;
form1.MediaPlayer1.Pause;
form2.MediaPlayer1.Position:=form1.MediaPlayer1.Position;
form2.MediaPlayer1.Play;
end;




end.

 
后退
顶部