I have a sound effect that I am playing repeatedly using PlayAmbientSound, and it works beautifully, until I click on another window (say, Firefox, to read the AGS forums), at which point the sound stops (rightly enough) and then click back on the game window, at which point the sound does not start playing again.
Is this a bug in AGS, or am I doing something wrong? Is there a workaround? Adding the following to repeatedly_execute_always (with channel = 1, sound = 1, maxVolume = 255, as in the original call to the function) does not solve the problem:
if (!IsSoundPlaying())
PlayAmbientSound(channel, sound, maxVolume, 0, 0);
I'm using AGS v2.71.
Thanks.
I tried this using AGS 2.71 and for me, it works just fine. As soon as the window gains focus back, the sound continues exactly where it left off (wav as well as ogg).
Thanks for that. Hm, I'm not sure why it doesn't work for me.
I've found a workaround, though:
SetMultitaskingMode(1);
This keeps the game running when the window loses the focus. Not perfect, because it means the player might miss part of a cutscene this way, but at least it gets round the problem I'm seeing.
This does sound like a bug. I'd suggest you grab the last version of the AGS 2.7 line.
Thanks. It seems to happen on and off. I'm now using the setting that means the ambient sound keeps when the room changes, but I haven't tested to see if the problem is still happening.
I changed from 2.71 to 2.72 without having any problems adjusting so.. try it out.