2个回答
展开全部
使用Api函数MCISendString实现你要的功能,连控件都省去不要了,使程序非常精简。
注意:首先在单元接口增添 mmsystem 单元以供引用。
一.播放mid音乐
procedure TForm1.midButton1Click(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.midButton2Click(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;
//播放.MP3文件:
procedure TForm1.mp3Button1Click(Sender: TObject);//播放
begin
MCISendString('OPEN e:\1.mp3 TYPE mpegvideo alias ww',nil, 0, 0);
MCISendString('PLAY WW', nil, 0, 0);
MCISendString('CLOSE ANIMATION', '', 0, 0);
end;
//停止播放
procedure TForm1.mp3Button2Click(Sender: TObject);
begin
MCISendString('OPEN e:\1.mp3 TYPE mpegvideo alias ww', '', 0, 0);
MCISendString('STOP ww', '', 0, 0);
MCISendString('CLOSE ANIMATION', '', 0, 0);
end;
注意:首先在单元接口增添 mmsystem 单元以供引用。
一.播放mid音乐
procedure TForm1.midButton1Click(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.midButton2Click(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;
//播放.MP3文件:
procedure TForm1.mp3Button1Click(Sender: TObject);//播放
begin
MCISendString('OPEN e:\1.mp3 TYPE mpegvideo alias ww',nil, 0, 0);
MCISendString('PLAY WW', nil, 0, 0);
MCISendString('CLOSE ANIMATION', '', 0, 0);
end;
//停止播放
procedure TForm1.mp3Button2Click(Sender: TObject);
begin
MCISendString('OPEN e:\1.mp3 TYPE mpegvideo alias ww', '', 0, 0);
MCISendString('STOP ww', '', 0, 0);
MCISendString('CLOSE ANIMATION', '', 0, 0);
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询