Created
November 20, 2014 21:56
-
-
Save taka75/67f38b82111f079adc34 to your computer and use it in GitHub Desktop.
test audio tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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