我以前的播放单个文件的代码是这样:
procdeure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
ShockwaveFlash1.Movie:= OpenDialog1.FileName;
end;
procdeure TForm1.Button2Click(Sender: TObject);
begin
ShockwaveFlash1.Play;
end;
现在的代码是这样:
procdeure TForm1.Button1Click(Sender: TObject);
var
i: integer;
begin
if OpenDialog1.Execute then
begin
for i:=0 to OpenDialog1.Files.Count-1do
ListBox1.Items.add(ExtractFileName(OpenDialog1.Files));
end;
//把文件都保存到ListBox1里去了
end;
procdeure TForm1.Button2Click(Sender: TObject);
begin
ShockwaveFlash1.Play;
//怎样实现选中一个文件后,按下此按钮,即开始播放?
end;
还是不行啊,请各位大虾帮我看看,谢谢了!
以下是现在的代码:
var s: string;
procedure TFlashPlayer.OpenBtnClick(Sender: TObject);
var
i: integer;
begin
if OpenDialog1.Execute then
begin
for i:=0 to OpenDialog1.Files.Count-1do
ListBox1.Items.add(ExtractFileName(OpenDialog1.Files));
end;
end;
procedure TFlashPlayer.ListBox1Click(Sender: TObject);
begin
s:=ListBox1.Items[ListBox1.ItemIndex];
end;
试一下下面的行不行:
先定义全局变量s:string
procedure TFlashPlayer.OpenBtnClick(Sender: TObject);
var
i: integer;
begin
if OpenDialog1.Execute then
begin
for i:=0 to OpenDialog1.Files.Count-1do
ListBox1.Items.add(ExtractFileName(OpenDialog1.Files));
end;
s:=ExtractFilePath(OpenDialog1.Files[0]);
end;
procedure TFlashPlayer.ListBox1Click(Sender: TObject);
begin
s:=s+ListBox1.Items[ListBox1.ItemIndex];
end;
procedure TFlashPlayer.PlayBtnClick(Sender: TObject);
begin
ShockwaveFlash1.Playing:=true;
ShockwaveFlash1.Movie:=s;
end;