Created
November 14, 2014 10:16
-
-
Save tai2/0d1f39674adf0972388b to your computer and use it in GitHub Desktop.
web audio test 1
This file contains hidden or 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="music1" src="http://1.ice1.firststreaming.com:8000/gndr_fm.mp3" loop></audio> | |
| <audio id="music2" src="http://144.76.39.90:8000/albayane.mp3" loop></audio> | |
| </div> | |
| <button id="button1">play music1</button> | |
| <button id="button2">play music2</button> | |
| <script> | |
| (function() { | |
| var music1 = document.getElementById('music1'); | |
| var music2 = document.getElementById('music2'); | |
| music1.isPlayed = false; | |
| music2.isPlayed = false; | |
| var button1 = document.getElementById('button1'); | |
| button1.addEventListener('click', function(event) { | |
| if (music1.isPlayed) { | |
| music1.pause(); | |
| music1.isPlayed = false; | |
| } else { | |
| music1.play(); | |
| music1.isPlayed = true; | |
| } | |
| }); | |
| var button2 = document.getElementById('button2'); | |
| button2.addEventListener('click', function(event) { | |
| if (music2.isPlayed) { | |
| music2.pause(); | |
| music2.isPlayed = false; | |
| } else { | |
| music2.play(); | |
| music2.isPlayed = true; | |
| } | |
| }); | |
| })(); | |
| </script> | |
| </body> | |
| </html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment