我用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.
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.
编译器会报错可能是:Tmediaplayer没有close.
哪位有没现成的源代码能贴上来的?
STOP和PAUSE都是灰色的.
autoplay:=true;
display:=panel1;
play;
MediaPlayer1.DeviceID<>0
哪位大虾在WIN2000下写过这种程序,把源码贴来瞧瞧.
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.