Looping AVIs
Question
I have an AVI which I want to loop continuously on my form. I though of a
FOR, or WHILE or REPEAT structure, but nothing worked because of the length
of the AVI.
Nevertheless, I found a solution using the TTimer and giving it as interval
the duration of the AVI. Is there any more convenient way to do this?
Answer
A:
Use the mediaplayer's OnNotify event so it will let you know when it's finished:
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
With MediaPlayer1 do
Begin
Open;
Notify := True;
Play;
End;
end;
procedure TForm1.MediaPlayer1Notify(Sender: TObject);
begin
With MediaPlayer1 do
If NotifyValue = nvSuccessful
Then
Begin
Notify := True;
Play;
End;
end;
Determining CD track with TMediaPlayer
Question
How to determine CD track with TMediaPlayer?
Answer
{
Create a timer and put this code in the OnTimer event:
}
var Trk, Min, Sec: Word;
begin
with MediaPlayer1 do
begin
Trk:= MCI_TMSF_TRACK(Position);
Min:=MCI_TMSF_MINUTE(Position);
Sec:=MCI_TMSF_SECOND(Position);
Label1.Caption:=Format('%.2d',[Trk]);
Label2.Caption:=Format('%.2d:%.2d',[Min,Sec]);
end;
end;
{
Add MMSystem to the uses clause in Unit1
This will show current track and time.
}