How do i see the current position in time of a BGM while its playing?

Ive been researching around and i havent found any kind of solution to this.
I want to change the BGM dynamically between maps useing a script(or plugin? not sure what to call it) but for that i need to be able to figure out the position in time that the music is at and change the music with that data.
Why do I have a feeling you pasted a post from google translator, but If I understand you correctly, then let's clarify one thing, natively you cannot do it, but maybe this will help. also you could try to install this package to your nwjs and use this instead.
Oh i already figured out how to do what i wanted to do, but thanks alot!
That package also could help me later as well
natively you cannot do it
That's not correct. The pos member variable will return the current position in an audio track. So, for example, AudioManager._currentBgm.pos should return the current position in the currently-playing BGM, and then
Code:
// Start 'Battle3' BGM at 10 seconds
AudioManager.playBgm({ name: 'Battle3', volume: 50, pitch: 100, pan: 0, pos: 10 }, 10);
@ATT_Turan 50/50 you're right: variable "pos" indeed is in audio manager, but it returns undefined - link
I can't speak to that, but it is obviously supported natively because your map BGM's position is saved when you get into a battle - it doesn't restart from the beginning when you get back.

So someone who's more interested than I am could look at the code that starts encounters.
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.

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-see-the-current-position-in-time-of-a-bgm-while-its-playing.143639/