Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: paolo on Sun 20/01/2008 10:17:42

Title: PlayAmbientSound turns off when window loses the focus
Post by: paolo on Sun 20/01/2008 10:17:42
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.
Title: Re: PlayAmbientSound turns off when window loses the focus
Post by: Khris on Sun 20/01/2008 11:51:10
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).
Title: Re: PlayAmbientSound turns off when window loses the focus
Post by: paolo on Sun 20/01/2008 15:08:17
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.
Title: Re: PlayAmbientSound turns off when window loses the focus
Post by: Radiant on Mon 21/01/2008 12:42:59
This does sound like a bug. I'd suggest you grab the last version of the AGS 2.7 line.
Title: Re: PlayAmbientSound turns off when window loses the focus
Post by: paolo on Mon 21/01/2008 18:43:42
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.
Title: Re: PlayAmbientSound turns off when window loses the focus
Post by: Dualnames on Tue 22/01/2008 11:18:19
I changed from 2.71 to 2.72 without having any problems adjusting so.. try it out.