Warum nicht ohne Timer? Zum Beispiel in nem Button-Click (ungetestet):
Delphi-Quellcode:
type
TRunState = (rsIdle, rsFirst, rsSecond);
var
PanelState: Byte;
RunState: TRunState;
StartMs,
CurrentMs,
TargetMs: Cardinal;
begin
StartMs := GetTickCount;
RunState := rsFirst;
while AbbruchBedingungNichtErfuellt do
begin
case RunState of
rsFirst:
begin
StartMs := GetTickCount;
MediaPlayer1.Play;
Panel2.Visible:= false;
Panel1.Visible:= true;
TargetMs := 21000;
PanelState := 2;
RunState := rsIdle;
end;
rsSecond:
begin
StartMs := GetTickCount;
MediaPlayer1.Stop;
Panel2.Visible:= true;
Panel1.Visible:= false;
TargetMs := 10000;
PanelState := 1;
RunState := rsIdle;
end;
rsIdle:
begin
CurrentMs := GetTickCount;
if (CurrentMs - StartMs >= TargetMs) then
begin
StartMs := GetTickCount;
case PanelState of
1: RunState := rsFirst;
2: RunState := rsSecond;
end;
end;
end;
end;
Application.ProcessMessages; // oder ähnliches
end;
end;