C
cqjxnc
Unregistered / Unconfirmed
GUEST, unregistred user!
我在程序中利用了多媒体mmsystem单元的Api函数mcisendcommand写了一个函数,但是如果利用此函数播放文件后,程序可以播放文件,但是不能响应其他事件,即窗体不能响应事件,窗体会发白。是不是要写一个线程。但是我看了Delphi自带组件MediaPlayer的MPlayer单元中的代码,发现其中并没有线程代码。各位大侠请问如何实现?
function PlayMedia(filename:String):Integer;stdcall;
var
OpenParm:TMCI_Open_Parms;
PlayParm: TMCI_Play_Parms;
Error: Longint;
begin
OpenParm.dwCallback := 0;
OpenParm.lpstrDeviceType := PChar(typeDevice);
OpenParm.lpstrElementName := PChar(filename);
Error:=mciSendCommand(1, mci_Open,mci_Wait or MCI_OPEN_ELEMENT, Longint(@OpenParm));
if Error=0 then
begin
PlayParm.dwCallback := 1;
mciSendCommand(1, mci_Play, mci_Wait, Longint(@PlayParm));
end
else
raise Exception.Create('不能识别该音频格式!');
end;
function PlayMedia(filename:String):Integer;stdcall;
var
OpenParm:TMCI_Open_Parms;
PlayParm: TMCI_Play_Parms;
Error: Longint;
begin
OpenParm.dwCallback := 0;
OpenParm.lpstrDeviceType := PChar(typeDevice);
OpenParm.lpstrElementName := PChar(filename);
Error:=mciSendCommand(1, mci_Open,mci_Wait or MCI_OPEN_ELEMENT, Longint(@OpenParm));
if Error=0 then
begin
PlayParm.dwCallback := 1;
mciSendCommand(1, mci_Play, mci_Wait, Longint(@PlayParm));
end
else
raise Exception.Create('不能识别该音频格式!');
end;