请问如何用TMEDIAPLAYER实现自动播放VCD啊?

SODATEA 2003-09-30 01:50:33
最好STEP BY STEP
小弟先谢过
...全文
40 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ljianq 2003-09-30
  • 打赏
  • 举报
回复
监视CD-ROM,发现VCD则播放。
zihan 2003-09-30
  • 打赏
  • 举报
回复
不好意思.刚才把两个东西帖错地方了.
监视光驱中是否有光盘
拦截消息WM_DEVICECHANGE即可!
//响应该消息

procedure Tform1.WMDEVICECHANGE(var msgx :Tmessage);

const

DBT_DEVICEARRIVAL=$8000;
DBT_DEVICEREMOVECOMPLETE=$8004;

begin

inherited;

case msgx.WParam of

DBT_DEVICEARRIVAL:Caption :='有了!';

DBT_DEVICEREMOVECOMPLETE:Caption :='取走了';

end;

end;



判断光驱中的Audio cd

function IsAudioCD(Drive : char) : bool;
var
DrivePath : string;
MaximumComponentLength : DWORD;
FileSystemFlags : DWORD;
VolumeName : string;
begin
Result := false;
DrivePath := Drive + ':\';
if GetDriveType(PChar(DrivePath)) <> DRIVE_CDROM then exit;
SetLength(VolumeName, 64);
GetVolumeInformation(PChar(DrivePath),
PChar(VolumeName),
Length(VolumeName),
nil,
MaximumComponentLength,
FileSystemFlags,
nil,
0);
if lStrCmp(PChar(VolumeName),'Audio CD') = 0 then result := true;
end;

function PlayAudioCD(Drive : char) : bool;
var
mp : TMediaPlayer;
begin
result := false;
Application.ProcessMessages;
if not IsAudioCD(Drive) then exit;
mp := TMediaPlayer.Create(nil);
mp.Visible := false;
mp.Parent := Application.MainForm;
mp.Shareable := true;
mp.DeviceType := dtCDAudio;
mp.FileName := Drive + ':';
mp.Shareable := true;
mp.Open;
Application.ProcessMessages;
mp.Play;
Application.ProcessMessages;
mp.Close;
Application.ProcessMessages;
mp.free;
result := true;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if not PlayAudioCD('D') then
ShowMessage('Not an Audio CD');
end;
zihan 2003-09-30
  • 打赏
  • 举报
回复
监视光驱中是否有光盘
拦截消息WM_DEVICECHANGE即可!
//响应该消息

procedure Tform1.WMDEVICECHANGE(var msgx :Tmessage);

const

DBT_DEVICEARRIVAL=$8000;


判断光驱中的Audio cd

function IsAudioCD(Drive : char) : bool;
var
DrivePath : string;
MaximumComponentLength : DWORD;
FileSystemFlags : DWORD;
VolumeName : string;
begin
Result := false;
DrivePath := Drive + ':\';
if GetDriveType(PChar(DrivePath)) <> DRIVE_CDROM then exit;
SetLength(VolumeName, 64);
GetVolumeInformation(PChar(DrivePath),
PChar(VolumeName),
Length(VolumeName),
nil,
MaximumComponentLength,
FileSystemFlags,
nil,
0);
if lStrCmp(PChar(VolumeName),'Audio CD') = 0 then result := true;
end;

function PlayAudioCD(Drive : char) : bool;
var
mp : TMediaPlayer;
begin
result := false;
Application.ProcessMessages;
if not IsAudioCD(Drive) then exit;
mp := TMediaPlayer.Create(nil);
mp.Visible := false;
mp.Parent := Application.MainForm;
mp.Shareable := true;
mp.DeviceType := dtCDAudio;
mp.FileName := Drive + ':';
mp.Shareable := true;
mp.Open;
Application.ProcessMessages;
mp.Play;
Application.ProcessMessages;
mp.Close;
Application.ProcessMessages;
mp.free;
result := true;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if not PlayAudioCD('D') then
ShowMessage('Not an Audio CD');
end;

DBT_DEVICEREMOVECOMPLETE=$8004;

begin

inherited;

case msgx.WParam of

DBT_DEVICEARRIVAL:Caption :='有了!';

DBT_DEVICEREMOVECOMPLETE:Caption :='取走了';

end;

end;



SODATEA 2003-09-30
  • 打赏
  • 举报
回复
最好STEP BY STEP
谢谢先……
具体代码的用法,越简单越好

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧