怎样实现在delphi开发程序中实现背景音乐?着急!!!!! 哪位神仙告诉我,谢啦 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在Form 上 放一个MediaPlayer1控件.设置如下属性: MediaPlayer1.Visible:=false; MediaPlayer1.filename:='Sound.midi'; Mediaplayer.AutoOpen:=true;然后在你需要音乐的时候调用: MediaPlayer1.Play;即可. 因为两个人给回复,所以可否一人给十分!sorry!!!还有如何给你分!!望告之!!谢谢!!! unit Unit1;interfaceuses Windows, Messages, mmsystem,SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); protected procedure MCINOTIFY(Var Message:TMessage); message MM_MCINOTIFY; private nowloop:boolean; function SendMCIStr(Const Msg:String):PChar; { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.DFM}{打开并播放}procedure TForm1.Button1Click(Sender: TObject);beginSendMciStr('open c:\123.mid alias mid');Sendmcistr('play mid notify');Nowloop:=true;end;{Callback}procedure TForm1.MCINOTIFY(var Message: TMessage);beginif nowloop and (SendmciStr('Status mid mode')='stopped') thenbegin sendmcistr('seek mid to start'); sendmcistr('play mid notify');end;end;{暂停(实际上是停止,但效果一样)}procedure TForm1.Button2Click(Sender: TObject);begin nowloop:=False; mcisendstring('stop mid',nil,0,0);end;{恢复(实际上是从当前位置播放,效果一样,因为SEQ设备不支持Resume命令)}procedure TForm1.Button3Click(Sender: TObject);begin nowloop:=true; sendmcistr('play mid notify');end;{关闭}procedure TForm1.Button4Click(Sender: TObject);begin sendmcistr('close mid');end;{公用函数}function TForm1.SendMCIStr(const Msg: String): PChar;Var Buf:Array[0..4095] of Char;begin MciSendString(PChar(msg),Buf,sizeof(buf),Handle); Result:=Buf;end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);begin button4click(nil);end;end. 为什么我绘制drawgrid单元格有时候可以有时候不可以呢? 用户只读权限设计 请问如何在TreeView中实现支持添加子节点? 用bde还是ado!请大家给一个建议! Rainsea散分帖,问候大家春节好,向各位和各位家人拜早年了!年后结帖! 动态建立的tabsheet(属于pagecontrol),如何释放? 回答了1070個問題有221個得分;得分率高嗎? 请问各位高手,怎样动态生成一个控件??谢谢!! 分不多了,但问题是要解决的。我的程序到底错在哪里????? ApplyUpdates(0)成功保存后问题 treeview控件的问题 开发vcl控件问题!
设置如下属性:
MediaPlayer1.Visible:=false;
MediaPlayer1.filename:='Sound.midi';
Mediaplayer.AutoOpen:=true;然后在你需要音乐的时候调用:
MediaPlayer1.Play;
即可.
还有如何给你分!!望告之!!谢谢!!!
Windows, Messages, mmsystem,SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
protected
procedure MCINOTIFY(Var Message:TMessage); message MM_MCINOTIFY;
private
nowloop:boolean;
function SendMCIStr(Const Msg:String):PChar;
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}{打开并播放}
procedure TForm1.Button1Click(Sender: TObject);
begin
SendMciStr('open c:\123.mid alias mid');
Sendmcistr('play mid notify');
Nowloop:=true;
end;{Callback}
procedure TForm1.MCINOTIFY(var Message: TMessage);
begin
if nowloop and (SendmciStr('Status mid mode')='stopped') then
begin
sendmcistr('seek mid to start');
sendmcistr('play mid notify');
end;
end;{暂停(实际上是停止,但效果一样)}
procedure TForm1.Button2Click(Sender: TObject);
begin
nowloop:=False;
mcisendstring('stop mid',nil,0,0);
end;{恢复(实际上是从当前位置播放,效果一样,
因为SEQ设备不支持Resume命令)}
procedure TForm1.Button3Click(Sender: TObject);
begin
nowloop:=true;
sendmcistr('play mid notify');
end;{关闭}
procedure TForm1.Button4Click(Sender: TObject);
begin
sendmcistr('close mid');
end;{公用函数}
function TForm1.SendMCIStr(const Msg: String): PChar;
Var Buf:Array[0..4095] of Char;
begin
MciSendString(PChar(msg),Buf,sizeof(buf),Handle);
Result:=Buf;
end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
button4click(nil);
end;end.