Actions/Conditions for seeking music

Seeking music tracks to a particular timestamp is essential for dynamic music (to swap music tracks with a different one while staying in sync), so actions and conditions regarding this would be awesome.

In the meanwhile, I was hoping this can be achieved with already existing functions in the underlying tech of Gdevelop. I was poking around the howler-sound-manager.ts and saw the getSeek and setSeek functions. I tried working with the following code, the audio plays but functions like pause or setSeek don’t. Can anybody who knows Javascript and how the API works help me out?

let sound2 = runtimeScene.getSoundManager();
sound2.playSound("rdh.ogg", false, 15, 1);
sound2.pause();
sound2.setSeek(5500);

These exist. The conditions and actions for sounds (do not use the music events, they are a more legacy sound system) you want call it “offset”.

Edit:

Conditions:
image

Actions:
image

1 Like

:man_facepalming:

How could I have overlooked this? This works flawlessly!

For others, do note that you need to preload your files or else the seek won’t work in the first attempt.

This is correct, and why I usually recommend using the sound events. “preload as sound” being checked in resources avoids having to worry about any gaps when first playing a sound, and doesn’t require any events to preload the sounds in the scene.

1 Like