Skip to content

Instantly share code, notes, and snippets.

@brydavis
Last active May 9, 2019 23:15
Show Gist options
  • Save brydavis/fdff649fe8ba364761f7589514caaf83 to your computer and use it in GitHub Desktop.
Save brydavis/fdff649fe8ba364761f7589514caaf83 to your computer and use it in GitHub Desktop.
<audio id="player" src=""></audio>
<button id="play">play</button>
<button id="reset">reset</button>
var list = [
"https://upload.wikimedia.org/wikipedia/commons/3/37/Zh-bèijing.ogg",
"https://upload.wikimedia.org/wikipedia/commons/8/8a/Zh-Beijing.ogg",
"https://upload.wikimedia.org/wikipedia/commons/7/73/Zh-Shanghai.ogg",
]
var player = document.getElementById('player');
var i = 0
player.src = list[i]
player.onended = function(){
i++
player.src = list[i];
player.play()
}
$('#play').on('click', function() {
if (player.paused) {
player.play()
$(this).text("pause")
} else {
player.pause()
$(this).text("play")
}
})
$('#reset').on('click', function() {
player.currentTime = 0
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment