1
0
Fork 0

Hack for if autoplay is disabled

This commit is contained in:
Andrew Tomaka 2014-09-25 15:38:49 -04:00
parent 4b5e9bbf3a
commit 48389653d7

View file

@ -1,14 +1,7 @@
var playing = false; var sound = null;
var playing = true;
var control = document.getElementById('control'); var control = document.getElementById('control');
var background = document.getElementById('background'); var background = document.getElementById('background');
var sound = new Howl({
urls: ['assets/audio/africa.ogg', 'assets/audio/africa.m4a'],
autoplay: true,
loop: true,
onload: function() {
setTimeout(makeItPlay, 500);
}
});
function toggle() { function toggle() {
if(playing) { if(playing) {
@ -24,6 +17,16 @@ function toggle() {
function load() { function load() {
makeItRain(); makeItRain();
makeItPlay();
}
function makeItPlay() {
sound = new Howl({
urls: ['assets/audio/africa.ogg', 'assets/audio/africa.m4a'],
autoplay: true,
loop: true
});
setTimeout(enableToggle, 2500);
} }
function makeItRain() { function makeItRain() {
@ -37,9 +40,10 @@ function makeItRain() {
background.crossOrigin = 'anonymous'; background.crossOrigin = 'anonymous';
} }
var makeItPlay = function() { var enableToggle = function() {
if(sound.pos() === 0) { if(0 === sound.pos()) {
playing = false; playing = false;
control.className = 'icon-play';
control.style.visibility = 'visible'; control.style.visibility = 'visible';
} }
} }