我用TMEDIAPLAYER控件写了个过程如下:
procedure TMainForm.Button1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
    with MediaPlayer1 do
    begin
      Filename := OpenDialog1.Filename;
      Open;
      DisplayRect := Rect(0, 0, Panel1.Width, Panel1.Height);
    end;
end;
为什么每次关闭主窗口时编译器会报错,接着现出CPU查看窗口.如果用TRY.....FINALLY结构,一播放就会出错.
还有,每次打开媒体文件时为什么不能自动播放?
我用的是WIN2000+D6.

解决方案 »

  1.   

    每次打开媒体文件时不能自动播放的原因是:你应该在open语句下加上play语句。
    编译器会报错可能是:Tmediaplayer没有close.
      

  2.   

    設置AutoOpen屬性為true---------自動播放
      

  3.   

    我用TRY....FINALLY结构和在窗口关闭时停止和释放了TMEDIAPLAYER组件,编译器还是要报错.
    哪位有没现成的源代码能贴上来的?
      

  4.   

    还有,自动播放后,为什么只有PLAY按键可用.
    STOP和PAUSE都是灰色的.
      

  5.   

    你可以把mediaplayer 的visible设为false用其他的按钮实现stop,pause的功能
      

  6.   

    加上:
        autoplay:=true;
        display:=panel1;
        play;
      

  7.   

    再加一句:
    MediaPlayer1.DeviceID<>0
      

  8.   

    不行不行.
    哪位大虾在WIN2000下写过这种程序,把源码贴来瞧瞧.
      

  9.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      NMUDP, StdCtrls,WinSock, ExtCtrls, MPlayer, Buttons, ComCtrls,mmsystem,
      WaveControl, Menus;type
      TForm1 = class(TForm)
        Panel1: TPanel;
        VideoArea: TPanel;
        MediaPlayer1: TMediaPlayer;
        OpenDialog1: TOpenDialog;
        Button6: TButton;
        procedure FormClose(Sender: TObject; var Action: TCloseAction);
        procedure Button6Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;type  HMSRec = record
        Hours: byte;
        Minutes: byte;
        Seconds: byte;
        NotUsed: byte;  end;var
      Form1: TForm1;  TheCurPos: LongInt;const  StopAll    = $0;  //停止
      SaoTui     = $1;  //扫腿
      ShengJiang = $2;  //升降
      GuaFeng    = $4;  //刮风
      JiangYu    = $8;  //降雨
      PenShui    = $10; //喷水
      XiaXue     = $20; //下雪
      ZhengDong  = $40; //振动
      ShangDian  = $80; //闪电implementation{$R *.DFM}procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      MediaPlayer1.Close;
    end;procedure TForm1.Button6Click(Sender: TObject);
    begin
      if opendialog1.Execute then
       begin
       try
       mediaplayer1.filename:=opendialog1.filename;
       mediaplayer1.Open ;
       MediaPlayer1.TimeFormat := tfHMS;   MediaPlayer1.DisplayRect := rect(0,0,VideoArea.Width,VideoArea.Height);   except
          on emcideviceerror do
          showmessage('不支持此类型文件.');
       end;
       end;
    end;
    end.