Created
November 7, 2013 14:32
-
-
Save mikedugan/7355491 to your computer and use it in GitHub Desktop.
plays an audio element using HTML audio tags
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
| function playAudio(audio){ | |
| document.getElementById(audio).play(); | |
| } | |
| /* | |
| ---------Add the following to your HTML doc (somewhere above the JavaScript include) -------- | |
| <audio id="audio" src="audio.wma" preload="auto" controls></audio> | |
| --------Add this as an event handler to your documents opening <body> tag---------- | |
| onload="playAudio('audio')" | |
| ---------In your HTML <head> element, add the following ------------ | |
| <script src="scripts/audio.js" > |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment