Skip to content

Commit

Permalink
Prevent audio from playing repeatedly
Browse files Browse the repository at this point in the history
  • Loading branch information
hefengxian committed Mar 26, 2024
1 parent 8a9856e commit 9351200
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/pages/vocabulary/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ document.addEventListener('keydown', (ev) => {
}
})

let audio = null
function play(audioPath) {
const audio = document.createElement('audio')
if (audio) {
audio.pause()
audio.currentTime = 0
}
audio = document.createElement('audio')
audio.src = audioPath
console.log(audioPath)
audio.play()
}
</script>
Expand Down

0 comments on commit 9351200

Please sign in to comment.