Play audio seamlessly over multiple slides

Problem: Hi, I am currently designing a serious game with active presenter. In this game, I put maximum display time for each scene/slide, as I want the progression in the project to be action-driven and not time-driven.
In this project, I would like to have several audio tracks run as background music for specific sets of slides (corresponding to several subparts of the game).

My issue is the following:
I can’t seem to find a way to make a looped audio play continuously over multiple slides when the slide switch is action-driven. I managed to have the same audio track play over a given subset of slides in the project, but upon changing slides, the audio jumps to a specific time of the audio.

I think I understand what is going on, as the audio infinite loop will resume on the next slide at the specific point it stopped at after the max display duration of the previous slide. However, the result is a jumpy background audio that disrupts the flow of the game.

Is there any way to prevent this with a javascript to manage my audio tracks, such that it plays seamlessly across multiple slides, even though the slide switch is induced by and tied to user action (click, text prompt etc…) ?

Thanks in advance

ActivePresenter version: 9

OS: Windows

Notes:

Hi,

You can add the following script to the project’s On Load event (ActivePresenter > Project > Properties > Interactivity tab):
var bgMusic = prez.object(“BGMusic”);
if (!bgMusic)
return;
var player = bgMusic.mediaPlayer();
if (!player)
return;
player.play(0);

Please find the sample project below for your reference:
play audio seamlessly1.approj (2.6 MB)

Regards,

1 Like

Hi,

This works very well! However, how can I make it so it does not apply to the entire project, but a given set of slides for, say, track 1, and another set of slides for track 2 ?

I really want background music to be dynamic and represent changes in narration and environment in the game!

Best Regards,

In this case, you can add the audio object to the relevant set of slides and set it to be hidden initially by right-clicking the audio object and selecting Initially Hidden.

Then, use the following JavaScript:

  • To play the audio:
    prez.object('audio object name').player().play();
  • To pause the audio:
    prez.object('audio object name').player().pause();

If you want to trigger the audio when the slide is shown, place the script in the slide’s On Load event so it provides a clear indication of why the audio is playing on those slides.

Regards,

Hi,
This exactly what I needed for now! Thanks a lot for your help!
I might have follow-up questions in the near future, but you can consider this initial issue solved.

Kind Regards,

1 Like

I’m glad it helped! Feel free to reach out anytime if any follow-up questions come up.
I’m happy to help.

All the best,