Found this thread while looking for something similar and started a bit of investigation.
RPG Maker's AudioManager already has the ability to save the current music position.
Code:
var getBgmInfo = AudioManager.saveBgm();
getBgmInfo.pos;
The
AudioManager.saveBgm() function returns an object with the current Bgm including
name,
volume,
pitch,
pan and
pos.
The last line in this small code piece will than just directly access the
pos value and if used on the console return it there.
To start another track at a given position you need to start the track with the following code:
Code:
var myBgm = { name: "bgm name without the file extension", volume: 100, pitch: 100, pan: 0};
AudioManager.playBgm(myBgm,position_value);
This will start the track at the given position. (Depending on the situation you might also wanna play with the values of volume, pitch and pan)
Now combining this it would be something like this:
Code:
var getBgmInfo = AudioManager.saveBgm();
var newStartPos = getBgmInfo.pos;
var myBgm = { name: "bgm name without the file extension", volume: 100, pitch: 100, pan: 0};
AudioManager.playBgm(myBgm,newStartPos);
However you will still hear a noticeable gap between both sounds, as RPG Maker by default will only load the files when needed. So you should also get a preloading plugin and preload whatever song you wanna play next, so that there won't be the noticeable gap until it starts playing.
Not entirely sure if this is what you meant though.
Small Edit:
This method will only work if the new song is not the same song. If you want to jump to any specific position in the same song, this method will not work.
@ATT_Turan 50/50 you're right: variable "pos" indeed is in audio manager, but it returns undefined -
link
This is in fact also only 50/50 true.
It will return the position value the song was given in the playBgm function. In the most cases this is undefined, but if you were to play a bgm with playBgm and entering a position, the position value would be returned as whatever was entered there.