If you change this:
soundPlayer = new Audio(soundName).play();
To that:
soundPlayer = new Audio(soundName);
soundPlayer.play();
Your pause will work. The problem is that you have assigned a playback function to soundPlayer. SoundPlayer is no longer an Audio object.
Instead of stop () use:
soundPlayer.pause();
soundPlayer.currentTime = 0;
It works the way I expect.
source
share