Created
February 18, 2014 09:44
-
-
Save kuu/9067702 to your computer and use it in GitHub Desktop.
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> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=yes" /> | |
</head> | |
<body> | |
<button id="loadBtn">Load</button> | |
<button id="playBtn">Play</button> | |
<script> | |
document.addEventListener("DOMContentLoaded", function() { | |
var tLoadButton = document.getElementById('loadBtn'); | |
var tPlayButton = document.getElementById('playBtn'); | |
var tBGM = new Audio(); | |
var tSE = new Audio(); | |
var tBGMLoaded = false; | |
var tSELoaded = false; | |
tLoadButton.addEventListener('click', function () { | |
tBGM.src = 'bgm.mp3'; | |
tSE.src = 'fire.wav'; | |
tBGM.load(); | |
tSE.load(); | |
}, false); | |
tPlayButton.addEventListener('click', function () { | |
tSE.play(); | |
}, false); | |
tBGM.addEventListener('loadeddata', function () { | |
tBGMLoaded = true; | |
if (tSELoaded) { | |
tBGM.currentTime = 5.5; | |
tBGM.play(); | |
} | |
}, false); | |
tSE.addEventListener('loadeddata', function () { | |
tSELoaded = true; | |
if (tBGMLoaded) { | |
tBGM.currentTime = 5.5; | |
tBGM.play(); | |
} | |
}, false); | |
}, false); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment