Skip to content

Instantly share code, notes, and snippets.

@taka75
Created November 20, 2014 21:56
Show Gist options
  • Save taka75/67f38b82111f079adc34 to your computer and use it in GitHub Desktop.
Save taka75/67f38b82111f079adc34 to your computer and use it in GitHub Desktop.
test audio tag
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Web Audio Test</title>
</head>
<body>
<h1>Web Audio Test</h1>
<div>
<audio id="music" src="http://1.ice1.firststreaming.com:8000/gndr_fm.mp3" loop></audio>
</div>
<button id="button">play</button>
<script>
(function() {
var music = document.getElementById('music');
music.isPlayed = false;
var button = document.getElementById('button');
button.addEventListener('click', function(event) {
if (music.isPlayed) {
music.pause();
music.isPlayed = false;
} else {
music.play();
music.isPlayed = true;
}
});
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment