As the title says. My intent is to change temporarily to another song, then continue the first song from where it stopped.
Greater control when playing back BGM tracks · By
For what it's worth, RPG Maker has this functionality built-in, with "Save BGM" and "Replay BGM", though it only stores one track at a time.
Also, if the track you're switching to is fixed-length, you could just play an "ME", which stops the currently-playing track and then automatically switches back when the ME is finished. Obviously, though, this won't work for looping music.
If none of that is what you need, then this plugin DOES have a sort of solution with the "alias" feature. When you load a track, you can assign it an alias and refer to that alias when you play back. But you can reassign that alias and have it point to a different track instead. The track assigned to the alias will just be whichever track you loaded with that alias most recently. You can keep as many aliases at a time as you have loaded tracks, so the alias can be your "variable".
But... that wouldn't save the sample number. There is a point in what I've written for Jay's Journey Reimagined that pulls the sample number (for a different reason). Let me see... here it is. I set a variable to this, under "script":
AudioManager._bgmBuffer ? AudioManager._bgmBuffer.seek() : 0
Multiply that number by the sample rate (usually 44100) and that should be your sample number.