Fade then stop example (Delphi)

Started by sam_fisher,

sam_fisher

Is there any way to fade then stop a stream without halting the application in the process ? I am using the below code on a button and it works but while the code is running my application is halted and I am hoping there is a better method. Anyway here is the code


procedure TForm1.stop_btnClick(Sender: TObject);
Begin
 BASS_ChannelSlideAttributes(stream,-1,-2,-101,1000);
 While BASS_ChannelIsSliding(stream) <> 0 Do
begin
 Process Events
end;
 BASS_ChannelStop(stream);
 BASS_StreamFree(stream);
End;

Irrational86

replace
Pricess Events with this line:

Application.ProcessMessages;

AndrewJameson

Sorry ... not got the time to look into this but there must be an event callback that's relevant to solve this problem ... but you must avoid calls to Application.ProcessMessages at all costs, it's far from a ideal solution and can result in all sorts of problems ...

If you look at this loop ...

While BASS_ChannelIsSliding(stream) <> 0 Do
begin
Process Events
end;
 ... it'll consume 100% CPU resources !!!

Andrew

(If there's no answer shortly then I'll look into how it's done ... but someone else will know the answer ?)

Ian @ un4seen

Instead of waiting in a loop, you could use a sync (BASS_SYNC_SLIDE).