A Pen by Harry Newsome on CodePen.
Created
October 31, 2017 09:51
-
-
Save harrynewsome/cf0e867384fc0975ae46c8b21f7308ad to your computer and use it in GitHub Desktop.
aVOZoO
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
<a href="https://codepen.io/harrynewsome/pen/aVOZoO">hax</a> |
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
//Create the audio tag | |
var soundFile = document.createElement("audio"); | |
soundFile.preload = "auto"; | |
//Load the sound file (using a source element for expandability) | |
var src = document.createElement("source"); | |
// src.src = "https://music.wixstatic.com/preview/7a344d_b59ac25d509d44e78f4029bb83a746d7-128.mp3"; | |
soundFile.appendChild(src); | |
//Load the audio tag | |
//It auto plays as a fallback | |
soundFile.load(); | |
soundFile.volume = 1; | |
soundFile.play(); | |
//Plays the sound | |
function play() { | |
//Set the current time for the audio file to the beginning | |
soundFile.currentTime = 0.01; | |
soundFile.volume = volume; | |
//Due to a bug in Firefox, the audio needs to be played after a delay | |
setTimeout(function(){soundFile.play();},1); | |
} | |
setTimeout(function(){ | |
console.log("refreshing"); | |
$('a').click(); | |
}, 2000); |
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
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment