Created
January 23, 2017 16:44
-
-
Save bora89/4e3d239e7b8d71b2f9670952b84e5ebc to your computer and use it in GitHub Desktop.
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 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html> | |
<head> | |
<title>Audio test</title> | |
<script type="text/javascript"> | |
/** | |
* @param {string} filename The name of the file WITHOUT ending | |
*/ | |
function playSound(filename){ | |
document.getElementById("sound").innerHTML='<audio autoplay="autoplay"><source src="' + filename + '.mp3" type="audio/mpeg" /><source src="' + filename + '.ogg" type="audio/ogg" /><embed hidden="true" autostart="true" loop="false" src="' + filename +'.mp3" /></audio>'; | |
} | |
</script> | |
</head> | |
<body> | |
<!-- Will try to play bing.mp3 or bing.ogg (depends on browser compatibility) --> | |
<button onclick="playSound('bing');">Play</button> | |
<div id="sound"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment