Hi,
ich mache gerade für die neue Version meines Players die TrackBar.
Ich habe eine Art "Endlos-Rekursion":
- Abspielen
- Passe die Position mit Timer an (Teil 1 der Rekursion)
- Wenn Change, dann passe an (Teil 2 der Rekursion)
Dadurch stockt es.
Wie kann ich das verhindern ? Hier der Code:
Delphi-Quellcode:
property Position: Longword read GetPosition write SetPosition;
procedure TfrmMain.SetPosition(Position: Longword);
var pos: Longword;
begin
if Chan = 0 then Exit;
if Modus = moSamples then
BASS_ChannelSetPosition(Chan, BASS_ChannelSeconds2Bytes(Chan,
position));
if Modus = moMusik then
begin
startmodplaytime := timegettime - (position * 1000);
pos := round(position * (SpeedinProzent / 100)) or $FFFF0000;
BASS_ChannelSetPosition(Chan, pos);
end;
end;
function TfrmMain.GetPosition: Longword;
var uptime: integer;
begin
Result := 0;
if Chan = 0 then Exit;
if Modus = moSamples then
Result := round(BASS_ChannelBytes2Seconds(Chan,
BASS_ChannelGetPosition(Chan)));
if Modus = moMusik then
begin
uptime := timegettime;
Result := (uptime - startmodplaytime) div 1000;
end;
end;
procedure TfrmMain.tb1Change(Sender: TObject);
begin
if BASS_ChannelIsActive(chan) = BASS_ACTIVE_PLAYING then
begin
Position := tb1.Position;
end;
end;
procedure TfrmMain.tbTimer(Sender: TObject);
var
sectime, trackpos : Integer;
str:string;
begin
if BASS_ChannelIsActive(chan) = BASS_ACTIVE_PLAYING then
begin
tb1.Position := Position;
sectime := trunc(BASS_ChannelBytes2Seconds(chan, BASS_ChannelGetPosition(chan)));
str := '';
if (sectime mod 60 < 10) then str := '0';
str := str+inttostr(sectime mod 60);
str := inttostr(sectime div 60)+':'+str;
tbtime.Caption := str;
end;
end;