我创建了一个播放声音文件的线程,执行后只能播放一段,而不能循环播放,也不能停止其播放。如下:
......
function ThreadPlay(p:pointer):longint;stdcall;
function ThreadStop(p:pointer):longint;stdcall;
implementationfunction ThreadPlay(p:pointer):longint;stdcall;
begin
sndPlaySound ('s.wav',SND_LOOP or SND_SYNC);
end;function ThreadStop(p:pointer):longint;stdcall;
begin
sndPlaySound (nil,SND_LOOP or SND_SYNC);
end;//播放过程
procedure TForm1.btn_playClick(Sender: TObject);
var hThread:Thandle;
ThreadID:DWord;
begin
try
hThread:=createthread(nil,0,@ThreadPlay,nil,0,ThreadID);
except
messagebox(handle,'error',nil,mb_ok);
end;
end;//停止过程
procedure TForm1.btn_stopClick(Sender: TObject);
var hThread:Thandle;
ThreadID:DWord;
begin
try
hThread:=createthread(nil,0,@ThreadStop,nil,0,ThreadID);
except
messagebox(handle,'error',nil,mb_ok);
end;
end;
各位大哥,帮忙看看,什么地方错了?
......
function ThreadPlay(p:pointer):longint;stdcall;
function ThreadStop(p:pointer):longint;stdcall;
implementationfunction ThreadPlay(p:pointer):longint;stdcall;
begin
sndPlaySound ('s.wav',SND_LOOP or SND_SYNC);
end;function ThreadStop(p:pointer):longint;stdcall;
begin
sndPlaySound (nil,SND_LOOP or SND_SYNC);
end;//播放过程
procedure TForm1.btn_playClick(Sender: TObject);
var hThread:Thandle;
ThreadID:DWord;
begin
try
hThread:=createthread(nil,0,@ThreadPlay,nil,0,ThreadID);
except
messagebox(handle,'error',nil,mb_ok);
end;
end;//停止过程
procedure TForm1.btn_stopClick(Sender: TObject);
var hThread:Thandle;
ThreadID:DWord;
begin
try
hThread:=createthread(nil,0,@ThreadStop,nil,0,ThreadID);
except
messagebox(handle,'error',nil,mb_ok);
end;
end;
各位大哥,帮忙看看,什么地方错了?
解决方案 »
- 又是一年过去了,有多少人想换换工作?
- Paradox7.x 数据库 T01.db 加密码后不能用sql访问???
- 我注册了sms.163.com的短信有没有直接登陆的url???
- 谁知道用QRShape控件画斜线?
- 谁能告诉我!!我想用DBComboBox把sql数据库中的所有数据库的名称列出来,如何实现?
- Help!
- 菜鸟问题:请教,如何在DBGrid中设置字段默认值和如何过滤DBGrid中重复字段?
- 有没有Delphi做的选修课管理系统啊 跪求
- 转载:一个程序员的忏悔录(巨长,慢慢看)
- 我的老婆看过来!
- SQL 语句超过255个字符怎么办.TADOcommand.commandtext是string类型,不能超过255个
- 怎么得到某个网页上具体文字的url? 解决就揭帖,在线等!
The sound plays repeatedly until sndPlaySound is called again with the lpszSoundName parameter set to NULL. You must also specify the SND_ASYNC flag to loop sounds.
2,播放完后就停止了啊,因为是同步的,我看停不了;