Music change script call help

Help with a script call

I have this script call i found on discord to be able to dynamically change a bmg with another one starting from the exact timestamp the old one stopped, but it always leavs a 1 second of silence between the two.
How do I eliminate said silence?

I can't ask the author of the code because i found it on discord and the person who sent it didn't provide source


Code:
const pos = AudioManager._bgmBuffer?.seek() ?? 0;
    AudioManager.playBgm({name: "MyBGM", volume: 90, pitch: 100, pan: 0}, pos);
Um.. I'm sry but your question didn't really make any.... sense, can you not just change the bgm using the event page?
1717804447737.png
The delay might be due the engine loading the file. Try preloading the bgm before your script call.
RPGMAKER MZ/MV's audio engine has a issue where your bgm could start delayed depending on how high your audio device's sample rate is in the OS settings. If you set the audio device your using's sample rate to high like (192000 hz 24bit My motherboard's max sample rate) It will be delayed. Its best to stay with your device's default sample rate when it comes to rpgmaker games.
1717809350105.png
Um.. I'm sry but your question didn't really make any.... sense
It makes perfect sense.

He said he wants to
change a bmg with another one starting from the exact timestamp the old one stopped
and the event command doesn't do that. It starts from the beginning of the new track, not the timestamp that the old one was at.

@AlexClips There have been a number of threads about this. For example:

That thread says the same thing @Slaughty did - you need to use some method to preload the new audio file in order for there to not be a break between the two.
That thread says the same thing @Slaughty did - you need to use some method to preload the new audio file in order for there to not be a break between the two.
I did look for preloading plugins, but google only gives me plugins for MV, not MZ. The only one I found for MZ doesn't work, as it gives syntax errors
Um.. I'm sry but your question didn't really make any.... sense, can you not just change the bgm using the event page?
View attachment 307874
Perhaps it would be better for you to not say anything if you have absolutely no idea how to aid the OP.

@AlexClips What kind of errors are you getting? Maybe they can be sorted out.
I did look for preloading plugins, but google only gives me plugins for MV, not MZ.
it might be worth giving the mv plugins a try if you havent. if it doesnt work it doesnt work, but under the hood, much of mv and mz are the same

Original thread: https://forums.rpgmakerweb.com/threads/music-change-script-call-help.169342/