I have a web based kisok, running on a raspberry pi, which plays sound continuously and displays information. Problem is that the audio gets interrupted when other things are happening. You hear lots of short pauses. For example when sometimes when I receive a mqtt message using (using Paho mqtt library) there is a pause. Or if I'm running a slideshow, there are lots of pauses when it's presumably loading the next image.
Is there any way to avoid this or can anyone explain why it happens?
I've noticed that if the audio player is isolated in a separate tab (chrome) it is unaffected by the other activities. But I would much prefer to keep everything on one page if possible.
Thanks!
I could imagine what is happening is the sound may be 2s long and if you get multiple "pings" this must completely play through still. The bypass is to pause the sound, set currentTime to 0 and re-play each message.
The result is that if you have ten messages coming in real quick, you'll hear 10 alerts but perhaps 0.1s 0.1s 0.1s ... 2s
mysound.pause();
mysound.currentTime = 0;
mysound.play();