方法如下:首先需要在uses部分加入mmsystem,接着写入下列语句,其中e:\1.mid为播放的文件,NN为自定义名称标志
procedure TForm1.Button1Click(Sender: Tobject);begin//播放音乐MCISendString('OPEN e:\1.MID TYPE SEQUENCER ALIAS NN', '', 0, 0);MCISendString('PLAY NN FROM 0', '', 0, 0);MCISendString('CLOSE ANIMATION', '', 0, 0);end;procedure TForm1.Button2Click(Sender: Tobject);
begin//停止播放MCISendString('OPEN e:\1.MID TYPE SEQUENCER ALIAS NN', '', 0, 0);MCISendString('STOP NN', '', 0, 0);MCISendString('CLOSE ANIMATION', '', 0, 0);end;