Sound Play / Stop / Pause
问题 I'm developing a sound JavaScript library. I can play sound with below code. var soundPlayer = null; function playSound(){ soundPlayer = new Audio(soundName).play(); } How can I stop and pause this audio? When I try like this: soundPlayer.pause(); Or soundPlayer.stop(); But I get this error: Uncaught TypeError: soundPlayer.stop is not a function How can I do that? 回答1: If you change that: soundPlayer = new Audio(soundName).play(); To that: soundPlayer = new Audio(soundName); soundPlayer.play(