Fading Background Music while a Video is played?

Started by Rik_Vargard, Fri 08/08/2025 19:34:16

Previous topic - Next topic

Rik_Vargard

Hiya! Well like the title says, I want to fade out a song while a video is played, if that's possible.

Here's what I got so far, looks like the video is blocking the script:
I tried both function room_RepExec() and function repeatedly_execute_always()
The Video plays first and only once it's finished does the fading happen.

Code: ags

function room_AfterFadeIn()
{
  SetTimer (1, 20);
  PlayVideo ("Video03.ogv", eVideoSkipAnyKeyOrMouse, 21);
}

function repeatedly_execute_always()
{
  if (IsTimerExpired (1))
  {
    if (BGM.Volume == 0)
    {
      SetTimer (1, 0);
    }
    else
    {
      BGM.Volume -= 1;
      SetTimer (1, 2);
    }
  }
}


Any ideas?  :)

Crimson Wizard

#1
The PlayVideo command in AGS stops the rest of the game completely, no script is run while it's playing.

AGS 4 has more advanced video controls, so this may be done easily there.

EDIT: I have a weird idea that maybe this could be done if you start crossfading to a another, silent music track right before PlayVideo. I have never tried that myself.

Rik_Vargard

Quote from: Crimson Wizard on Fri 08/08/2025 19:38:03AGS 4 has more advanced video controls, so this may be done easily there.

I can't wait to see what the Video part will be like in AGS 4  (nod)

Quote from: Crimson Wizard on Fri 08/08/2025 19:38:03EDIT: I have a weird idea that maybe this could be done if you start crossfading to a another, silent music track right before PlayVideo. I have never tried that myself.

Yeah my Eternal Scripting Noob Brain doesn't quite understand this.
But since AGS 4 will make that possible, let's forget this right now, I'll find another way to create that part.

Thanks a lot for replying.
Cheers! :)


Crimson Wizard

Quote from: Rik_Vargard on Fri 08/08/2025 22:07:07
Quote from: Crimson Wizard on Fri 08/08/2025 19:38:03EDIT: I have a weird idea that maybe this could be done if you start crossfading to a another, silent music track right before PlayVideo. I have never tried that myself.

Yeah my Eternal Scripting Noob Brain doesn't quite understand this.

This does not involve scripting. In AGS you can configure audio types to crossfade previous playing clips with the next clips.
If you add a silent music clip, you can start it after the previous music, and the music will crossfade to the silent clip, which may sound like it's fading away.

The problem is that I can't find how to only do this for certain pair of clips.
If it's not possible, then maybe there could be made a separate audio type just for this purpose (like "crossfading music" type).

Eon_Star

Hi,

Did not quite understand the question but you may have an audio track that  was formatted as a "fading out audio track" say using an audio editor. It might work.

Happy coding.


Rik_Vargard

Quote from: Crimson Wizard on Fri 08/08/2025 22:38:43This does not involve scripting. In AGS you can configure audio types to crossfade previous playing clips with the next clips.
If you add a silent music clip, you can start it after the previous music, and the music will crossfade to the silent clip, which may sound like it's fading away.

The problem is that I can't find how to only do this for certain pair of clips.
If it's not possible, then maybe there could be made a separate audio type just for this purpose (like "crossfading music" type).

Hey I really appreciate you trying to do whatever we can with what we have!  (nod)
But since you mentioned AGS 4 new Video possibilities, I finally found out another nice way for that moment in my game.
The reason, also, is that I stayed with "Videos block everything" in my head... so I was afraid nothing would work.
Thank you so much for your time!


Quote from: Eon_Star on Sat 09/08/2025 20:23:47Hi,
Did not quite understand the question but you may have an audio track that  was formatted as a "fading out audio track" say using an audio editor. It might work.
Happy coding.

Hey thx for your reply!
The thing here is that the music is a background music during a scene with dialogs, thus the player can skip whenever he wants, but the music still has to go on.
So I can't know how much time the player will be in that dialog.
That's the reason why I created that video with no sound, but being played while the background music is playing.

So there's no way I can calculate any timing in this case.

Cheers!  :)

Eon_Star

Hi,

I think you will do good with that idea of using AGS4. Keep up the good work @Rik_Vargard !

Happy coding.

Snarky


Rik_Vargard

Quote from: Snarky on Sun 10/08/2025 17:36:29
Quote from: Rik_Vargard on Fri 08/08/2025 22:07:07I can't wait to see what the Video part will be like in AGS 4  (nod)

Good news: You don't have to wait.

Thx for the reply. Yeah I'm aware, then there's that big warning sign  (laugh)
At this point I'll finish my game with the current version I'm using.

Cheers! :)

SMF spam blocked by CleanTalk