procedure TForm1.MediaPlayer1Notify(Sender: TObject); begin with Sender as TMediaPlayer do begin if Mode = mpStopped then begin //播放下一首歌 end; Notify := True; end; end;————————————————————————————————— 宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。 —————————————————————————————————
我的思路是:判断当前的position,,如果是最后就下一首歌,,
在mediaplayer1的onNotify事件中写: if (mediaplayer1.mode=mpStopped) and (mediaplayer1.NotifyValue=nvSuccessful) then
//双击文件列表框,选择开始播放的歌曲 procedure TForm1.FileListBox1DblClick(Sender: TObject); begin MediaPlayer1.FileName :=filelistbox1.FileName ; MediaPlayer1.Open ; MediaPlayer1.Notify :=true;//关键之处:该属性设为true 让MediaPlayer1成功调用 //play方法之后能够响应ONNotify事件 MediaPlayer1.play; end;//当一首歌曲播放完成时,响应如下事件 procedure TForm1.MediaPlayer1Notify(Sender: TObject); begin if filelistbox1.ItemIndex<filelistbox1.Items.Count then begin filelistbox1.ItemIndex:=filelistbox1.ItemIndex+1; MediaPlayer1.FileName :=filelistbox1.FileName ; MediaPlayer1.Open ; if filelistbox1.ItemIndex=filelistbox1.Items.Count-1 then MediaPlayer1.Notify :=false //当播放到最后一首时,停止响应ONNotify事件 else MediaPlayer1.Notify :=true; MediaPlayer1.play; end; end;
begin
with Sender as TMediaPlayer do
begin
if Mode = mpStopped then
begin
//播放下一首歌
end;
Notify := True;
end;
end;—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
if (mediaplayer1.mode=mpStopped) and
(mediaplayer1.NotifyValue=nvSuccessful) then
procedure TForm1.FileListBox1DblClick(Sender: TObject);
begin
MediaPlayer1.FileName :=filelistbox1.FileName ;
MediaPlayer1.Open ;
MediaPlayer1.Notify :=true;//关键之处:该属性设为true 让MediaPlayer1成功调用
//play方法之后能够响应ONNotify事件
MediaPlayer1.play;
end;//当一首歌曲播放完成时,响应如下事件
procedure TForm1.MediaPlayer1Notify(Sender: TObject);
begin
if filelistbox1.ItemIndex<filelistbox1.Items.Count then
begin
filelistbox1.ItemIndex:=filelistbox1.ItemIndex+1;
MediaPlayer1.FileName :=filelistbox1.FileName ;
MediaPlayer1.Open ;
if filelistbox1.ItemIndex=filelistbox1.Items.Count-1 then
MediaPlayer1.Notify :=false //当播放到最后一首时,停止响应ONNotify事件
else MediaPlayer1.Notify :=true;
MediaPlayer1.play;
end;
end;