I'm currently using the following code (C#):
private static void PlayLoop(string filename)
{
Audio player = new Audio(filename);
player.Play();
while (player.Playing)
{
if (player.CurrentPosition >= player.Duration)
{
player.SeekCurrentPosition(0, SeekPositionFlags.AbsolutePositioning);
}
System.Threading.Thread.Sleep(100);
}
}
This code works, and the file I'm playing is looping. But, obviously, there is a small gap between each playback.
- I tried reducing the Thread.Sleep it to 10 or 5, but the gap remains.
- I also tried removing it completely, but then the CPU usage raises to 100% and there's still a small gap.
Is there any (simple) way to make playback in DirectX gapless? It's not a big deal since it's only a personal project, but if I'm doing something foolish or otherwise completely wrong, I'd love to know.
Thanks in advance.