哪位神仙告诉我,谢啦

解决方案 »

  1.   

    在Form 上 放一个MediaPlayer1控件.
    设置如下属性:
     MediaPlayer1.Visible:=false;
     MediaPlayer1.filename:='Sound.midi';
     Mediaplayer.AutoOpen:=true;然后在你需要音乐的时候调用:
     MediaPlayer1.Play;
    即可.
      

  2.   

    因为两个人给回复,所以可否一人给十分!sorry!!!
    还有如何给你分!!望告之!!谢谢!!!
      

  3.   

    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);
    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.