主页 > 编程资料 > Delphi >
发布时间:2015-09-22 作者:网络 阅读:164次

delphi使用MCISendString播放背景音樂

播放文件為.MID文件:

在單元接口引用 mmsystem 單元.


//播放音乐
MCISendString('OPEN e:\1.MID TYPE SEQUENCER ALIAS NN', '', 0, 0);
MCISendString('PLAY NN FROM 0', '', 0, 0);
MCISendString('CLOSE ANIMATION', '', 0, 0);
end;
//停止播放
MCISendString('OPEN e:\1.MID TYPE SEQUENCER ALIAS NN', '', 0, 0);
MCISendString('STOP NN', '', 0, 0);
MCISendString('CLOSE ANIMATION', '', 0, 0);


播放.MP3文件:

//開始播放:

procedure TForm1.Button1Click(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.Button2Click(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;


关键字词: