listbox的name是lb1,mediaplayer的name是mp1。
程序如下:
procedure TForm1.mp1Notify(Sender: TObject);
begin
if mp1.Position=mp1.Length then
//放到了最后一首歌结束
if lb1.Items.Count-1=lb1.ItemIndex then
begin
lb1.ItemIndex:=0;
mp1.FileName:=lb1.Items.Strings[lb1.itemindex];
mp1.Open;
mp1.Play;
end
else
//没有放到最后一首歌
begin
lb1.ItemIndex:=lb1.ItemIndex+1;
mp1.FileName:=lb1.Items.Strings[lb1.itemindex];
mp1.Open;
mp1.Play;7
end;
end;