B
bestluo
Unregistered / Unconfirmed
GUEST, unregistred user!
我想选择几个mp3,把其文件按顺序保存到listbox中,然后在按顺序播放,但不知为什么其只能够播放一首.
我的代码如下:
//音乐之间间隔的长度
procedure TForm1.Timer1Timer(Sender: TObject);
begin
inc(i);
if i=5 then
timer1.Enabled :=false;
end;
//播放音乐的长度
procedure TForm1.Timer2Timer(Sender: TObject);
var
m:integer;
begin
for m:=0 to lengthdo
begin
inc(j);
end;
timer2.Enabled :=false;
timer1.Enabled :=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
i:=0;
j:=0;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
filename:string;
count,m:integer;//count:ÉùÒôÎļþÊý£¬i:ÓÃÓÚÑ­»·
begin
count:=listbox1.Count;
if count=0 then
begin
showmessage('ûÓÐÑ¡ÔñÒôƵÎļþ');
exit;
end;
//循环播放音乐
for m:=0 to count-1do
begin
filename:=listbox1.Items;
MediaPlayer1.FileName :=filename;
MediaPlayer1.Open;
MediaPlayer1.Play;
//开始播放音乐
length:=MediaPlayer1.Length div 100 +1;
timer2.Enabled :=true;
timer2.OnTimer(timer2);
end;
end;
我的代码如下:
//音乐之间间隔的长度
procedure TForm1.Timer1Timer(Sender: TObject);
begin
inc(i);
if i=5 then
timer1.Enabled :=false;
end;
//播放音乐的长度
procedure TForm1.Timer2Timer(Sender: TObject);
var
m:integer;
begin
for m:=0 to lengthdo
begin
inc(j);
end;
timer2.Enabled :=false;
timer1.Enabled :=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
i:=0;
j:=0;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
filename:string;
count,m:integer;//count:ÉùÒôÎļþÊý£¬i:ÓÃÓÚÑ­»·
begin
count:=listbox1.Count;
if count=0 then
begin
showmessage('ûÓÐÑ¡ÔñÒôƵÎļþ');
exit;
end;
//循环播放音乐
for m:=0 to count-1do
begin
filename:=listbox1.Items;
MediaPlayer1.FileName :=filename;
MediaPlayer1.Open;
MediaPlayer1.Play;
//开始播放音乐
length:=MediaPlayer1.Length div 100 +1;
timer2.Enabled :=true;
timer2.OnTimer(timer2);
end;
end;