S
sheian
Unregistered / Unconfirmed
GUEST, unregistred user!
我做了个程序,程序启动时自动播放背景音乐,当点击一个Button时,自动播放一个视频文件,此时背景音乐自动关闭,播放背景音乐我用的是线程,但不知道怎么在不关闭主程序时,去关闭背景音乐,有哪位大哥哥帮帮我啊?
主程序:
..............
procedure TFrmFirst.FormShow(Sender: TObject);
begin
....
ps := TPlaySound.Create(False);
end;
procedure TFrmFirst.Label10Click(Sender: TObject);
begin
ps.Terminate;
//有问题,关不掉线程
//其它事件
end;
以下为线程:
unit PlaySoundThread;
interface
uses
Classes, Mmsystem;
type
TPlaySound = class(TThread)
private
{ Private declarations }
protected
procedure Execute;
override;
procedure Play;
end;
implementation
{ TPlaySound }
procedure TPlaySound.Play;
begin
PlaySound('./video/play.wav',1,SND_ASYNC);
end;
procedure TPlaySound.Execute;
begin
Synchronize(Play);
end;
end.
主程序:
..............
procedure TFrmFirst.FormShow(Sender: TObject);
begin
....
ps := TPlaySound.Create(False);
end;
procedure TFrmFirst.Label10Click(Sender: TObject);
begin
ps.Terminate;
//有问题,关不掉线程
//其它事件
end;
以下为线程:
unit PlaySoundThread;
interface
uses
Classes, Mmsystem;
type
TPlaySound = class(TThread)
private
{ Private declarations }
protected
procedure Execute;
override;
procedure Play;
end;
implementation
{ TPlaySound }
procedure TPlaySound.Play;
begin
PlaySound('./video/play.wav',1,SND_ASYNC);
end;
procedure TPlaySound.Execute;
begin
Synchronize(Play);
end;
end.