Example of looping wav file #77
Closed
StacyPointe
started this conversation in
Q&A
Replies: 1 comment 1 reply
|
Hi, If you only want to play audio, then look for example, XAudio2Player Sample 1. Here you find function TXaudio2Engine.InitializeXAudio2 in unit TXaudio2Engine. When the mainform get's the signal the stream has been ended (procedure OnAudioEndedEvent) , just hit Playbutton again, until the number of times plaing has been reached. Like so: Basicly you can do the same with every MfPack sample. Regards, Tony. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Good day,
Can someone share an example of code to loop an audio file, say for example, 3 times when Play is triggered? Below is what I have:
procedure TMainForm.Timer1Timer(Sender: TObject);
var
position: LongInt;
FPlayCount : integer;
begin
Inc(FPlayCount);
if FPlayCount < 3 then
begin
trbPlayBackPosition.Position := 0;
g_MediaPlayer.Play();
end;
end
else
begin
Timer1.Enabled := False;
Label15.Caption := 'Audio has reached maximum loop limit.';
end;
end;
The concept is when a process completes, play an audio file. When the audio file reaches the end, increment FPlayCount and play again (until 3 times has been reached). When FPlayCount = 3, quit playing.
Thank you.
All reactions