Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: cat on Sun 11/01/2015 18:57:42

Title: AudioClip.Play stops background music
Post by: cat on Sun 11/01/2015 18:57:42
Hi!

I have a weird problem in my game: sometimes playing an audio stops the background music.
I have narrowed down WHEN it happens, but I don't know why or how I can solve the problem.

After an intro screen, the player enters the main room. There I start the music in room_FirstLoad()
Code (ags) Select
aKanji.Play(eAudioPriorityNormal, eRepeat);
Which works as expected. Later in the game, I play a sound when looking at an inventory item
Code (ags) Select
aRubberDuck.Play();
This sometimes stops the background music and it doesn't start again.
The weirdest thing is, when this happens. Because it all depends on the first intro screen.
The full room script:
Code (ags) Select

function room_AfterFadeIn()
{
   StartCutscene(eSkipESCOnly);   
   Wait(6 * GetGameSpeed());
   EndCutscene();
   aStart.Stop();
   player.ChangeRoom(1);
}

function room_Load()
{
   gInventory.Visible = false;
   aStart.Play(eAudioPriorityNormal, eOnce);
}

When I cancel the screen with ESC, everything is ok. But when I wait for the cutscene to finish, the aRubberDuck.Play() will stop the music later in the game.

What I intend to do is showing the intro screen and play the sound and only navigate to the main screen when the music has finished. When the user presses ESC, the game should stop the sound and switch to the main screen immediately.

My guess is, that aStart.Stop causes some internal error when the audio is not playing anymore, but I'm not sure.

Is my description clear? I know it sounds very confusing.

Is there a workaround for this problem?

Edit: I'm using AGS 3.3.3
Title: Re: AudioClip.Play stops background music
Post by: cat on Mon 12/01/2015 20:00:25
I found a workaround for this issue. I now store the AudioChannel in a variable and then only call Stop on the AudioChannel, not on the AudioClip. Still, this is some weird behaviour of AGS.
Title: Re: AudioClip.Play stops background music
Post by: Slasher on Tue 13/01/2015 10:53:20
I also had this same Music problem. Ags 3.2.1 somehow changed the Music properties setting on its own (roll)

I reset settings and now works.

They say strange is life (laugh)
Title: Re: AudioClip.Play stops background music
Post by: cat on Fri 23/01/2015 13:39:53
Not sure why this got stickied ???

Anyway, it is solved for me with the workaround. Should I investigate the issue further and submit a bug ticket to the tracker?
Title: Re: AudioClip.Play stops background music
Post by: Crimson Wizard on Fri 23/01/2015 13:47:02
Quote from: cat on Fri 23/01/2015 13:39:53
Anyway, it is solved for me with the workaround. Should I investigate the issue further and submit a bug ticket to the tracker?
Yes please, if you can confirm that its an engine behavior and not a scripting bug, put this on tracker. It is difficult to track such problems in forum threads.
Title: Re: AudioClip.Play stops background music
Post by: Silent Bob on Thu 30/07/2015 21:48:06
I've got the same problem. Sometimes the music just stops, and dono why. Sometimes it loops properly.
Title: Re: AudioClip.Play stops background music
Post by: Crimson Wizard on Thu 30/07/2015 22:04:55
Hmm, I vaguely remember this thread. I do not have any immediate ideas though.
I did not notice if cat actually open an issue in the tracker about this.

I will try to look into this using cat's script example; hopefully it will cause same error.
Title: Re: AudioClip.Play stops background music
Post by: Crimson Wizard on Sat 01/08/2015 15:51:25
I tried to use cat's example script, but could not reproduce the erroneous behavior.
I need more information on this error; ideally an exact steps to reproduce it (a project or script with instructions how to reach the bug).
Title: Re: AudioClip.Play stops background music
Post by: cat on Tue 01/09/2015 13:17:08
Sorry for not replying earlier, I just noticed that there was a follow-up on this topic.

Back then I tried to create a sample project that reproduces the error, but I was not able to do so. It was not reproducible.
I still don't know what exactly caused the problem.