PlayAmbientSound turns off when window loses the focus

Started by paolo, Sun 20/01/2008 10:17:42

Previous topic - Next topic

paolo

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:

Code: ags

if (!IsSoundPlaying())
    PlayAmbientSound(channel, sound, maxVolume, 0, 0);


I'm using AGS v2.71.

Thanks.

Khris

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).

paolo

Thanks for that. Hm, I'm not sure why it doesn't work for me.

I've found a workaround, though:

Code: ags

  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.

Radiant

This does sound like a bug. I'd suggest you grab the last version of the AGS 2.7 line.

paolo

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.

Dualnames

I changed from 2.71 to 2.72 without having any problems adjusting so.. try it out.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk