Skip preloader warning via settings

master
Will Toohey 9 years ago
parent 368d642bfe
commit 5d9833542e
  1. 5
      src/css/style.css
  2. 25
      src/js/HuesCore.js
  3. 10
      src/js/HuesSettings.js
  4. 18
      src/js/SoundManager.js

@ -159,6 +159,11 @@ h1, h2, h3 {
font-size: 12pt;
}
#preSub span {
font-size: 8pt;
opacity: 0.7;
}
#tabs {
margin: -1px;
padding-top: 22px;

@ -147,21 +147,36 @@ function HuesCore(defaults) {
this.soundManager = new SoundManager(this);
this.resourceManager.getSizes(defaults.respacks).then( sizes => {
this.soundManager.init().then(() => {
if(!this.soundManager.locked && localStorage["skipPreloader"] == "on") {
return null;
} else {
return this.resourceManager.getSizes(defaults.respacks);
}
}).then( sizes => {
if(sizes === null) {
return;
}
let size = sizes.reduce( (prev, curr) => {
return typeof curr === 'number' ? prev + curr : null;
});
}, 0);
if(typeof size === 'number') {
size = size.toFixed(1);
} else {
size = '<abbr title="Content-Length header not present for respack URLs">???</abbr>';
}
this.warning(size + "MB of music/images.<br />" +
let warning = size + "MB of music/images.<br />" +
"Flashing lights.<br />" +
"<b>Tap or click to start</b>");
"<b>Tap or click to start</b>";
return this.soundManager.init();
if(!this.soundManager.locked) {
warning += "<br /><span>Skip this screen from Options</span>";
}
this.warning(warning);
// Even if not locked, this steals clicks which is useful here
return this.soundManager.unlock();
}).then(() => {
this.clearMessage();
setInterval(this.loopCheck.bind(this), 1000);

@ -67,7 +67,8 @@ HuesSettings.prototype.defaultSettings = {
autoSongShuffle: "on",
autoSongFadeout: "on",
trippyMode: "off",
volume: 0.7
volume: 0.7,
skipPreloader: "off"
};
// Don't get saved to localStorage
@ -109,7 +110,8 @@ HuesSettings.prototype.settingsCategories = {
],
"Interface" : [
"currentUI",
"blackoutUI"
"blackoutUI",
"skipPreloader"
]
};
@ -198,6 +200,10 @@ HuesSettings.prototype.settingsOptions = {
shuffleImages : {
name : "Shuffle images",
options : ["off", "on"]
},
skipPreloader : {
name : "Skip preloader warning",
options : ["off", "on"]
}
};

@ -29,6 +29,8 @@ function SoundManager(core) {
this.song = null;
this.initPromise = null;
this.lockedPromise = null;
this.locked = true;
/* Lower level audio and timing info */
this.context = null; // Audio context, Web Audio API
@ -112,7 +114,17 @@ SoundManager.prototype.init = function() {
audioWorker.postMessage({ping:true, ogg:this.oggSupport});
});
}).then(() => {
return new Promise((resolve, reject) => {
this.locked = this.context.state != "running";
});
}
return this.initPromise;
};
SoundManager.prototype.unlock = function() {
if(this.lockedPromise) {
return this.lockedPromise;
}
this.lockedPromise = new Promise((resolve, reject) => {
// iOS and other some mobile browsers - unlock the context as
// it starts in a suspended state
let unlocker = () => {
@ -135,10 +147,8 @@ SoundManager.prototype.init = function() {
window.addEventListener('touchend', unlocker, false);
window.addEventListener('click', unlocker, false);
});
});
return this.lockedPromise;
}
return this.initPromise;
};
SoundManager.prototype.playSong = function(song, playBuild, forcePlay) {
let p = Promise.resolve();

Loading…
Cancel
Save