跟你播放参数设置有关系,估计你是采用异步方式播放声音文件。采用同步播放即可。 SND_SYNC Synchronous playback of a sound event. PlaySound returns after the sound event completes.SND_ASYNC The sound is played asynchronously and PlaySound returns immediately after beginning the sound. To terminate an asynchronously played waveform sound, call PlaySound with pszSound set to NULL.
不行啊,playsound播放外部文件也是放到一部分就重放了,怎么回事啊,急死我了
封装个函数给你用用procedure PlayMusic(FileName: String; Loop: Boolean=TRUE); var tmp: PChar; begin if not FileExists(FileName) then Exit; tmp := PChar(FileName); try if not Loop then tmp := nil; PlaySound(tmp,0,SND_LOOP); except end; end;如果想停掉播放,传参时,Loop设置成false即可。
SND_SYNC
Synchronous playback of a sound event. PlaySound returns after the sound event completes.SND_ASYNC
The sound is played asynchronously and PlaySound returns immediately after beginning the sound. To terminate an asynchronously played waveform sound, call PlaySound with pszSound set to NULL.
var
tmp: PChar;
begin
if not FileExists(FileName) then Exit;
tmp := PChar(FileName);
try
if not Loop then tmp := nil;
PlaySound(tmp,0,SND_LOOP);
except
end;
end;如果想停掉播放,传参时,Loop设置成false即可。