Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // play by JoeSimmons
- function play(src) {
- var elem = document.getElementById('sound_player'),
- body = document.body;
- src = src.replace(/\s/g, '%20').replace(/\\/g, '/');
- if (!elem) {
- elem = document.createElement('audio');
- elem.src = src;
- elem.id = 'sound_player';
- elem.setAttribute('autoplay', '');
- elem.setAttribute('preload', 'auto');
- elem.setAttribute('style', 'width: 1px; height: 1px; display: inline; visibility: hidden; position: fixed; top: 0; left: -9999px;');
- if (body) {
- body.appendChild(elem);
- }
- } else {
- if (elem.src !== src) {
- elem.src = src;
- } else {
- elem.play();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement