how to wait for BGM loop to end before playing new song

how do I do this?
if you use pixiSound libs, it easy and simple like that's.

PHP:
       instance.on('end', function() {
            // do you stuff
        });

by default rmmv don't support listener on web audio
if you use pixiSound libs, it easy and simple like that's.

PHP:
       instance.on('end', function() {
            // do you stuff
        });

by default rmmv don't support listener on web audio
how do I implement pixiSound libs?
the plugin is here
https://github.com/pixijs/pixi-sound
and demo
http://pixijs.io/pixi-sound/examples/demo.html

Original thread: https://forums.rpgmakerweb.com/threads/how-to-wait-for-bgm-loop-to-end-before-playing-new-song.98294/