Example of looping wav file #77
-
|
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); 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. |
Beta Was this translation helpful? Give feedback.
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. |
Beta Was this translation helpful? Give feedback.
Hi,
Using a timer is usually a bad idea. For instance some media files give an incorrect length.
What you should do, implement this in a callback or when the renderer signals playing has been ended (end of stream).
For example:
If you only want to play audio, then look for example, XAudio2Player Sample 1.
Here you find function TXaudio2Engine.InitializeXAudio2 in unit TXaudio2Engine.