Added touchLockedActionQueue property to HTML5AudioSound class

This commit is contained in:
Pavle Goloskokovic 2018-01-17 17:06:55 +01:00
parent c4f4fbc79d
commit 093f295389

View file

@ -44,6 +44,21 @@ var HTML5AudioSound = new Class({
* @default 0 * @default 0
*/ */
this.previousTime = 0; this.previousTime = 0;
/**
* A queue of all actions performed on a sound object while audio was locked.
* Once the audio gets unlocked, after an explicit user interaction,
* all actions will be performed in chronological order.
*
* @private
* @property {{
* sound: Phaser.Sound.HTML5AudioSound,
* type: string,
* name: string,
* value?: any,
* time: number,
* }[]} touchLockedActionQueue
*/
this.touchLockedActionQueue = manager.touchLocked ? [] : null;
this.duration = this.tags[0].duration; this.duration = this.tags[0].duration;
this.totalDuration = this.tags[0].duration; this.totalDuration = this.tags[0].duration;
BaseSound.call(this, manager, key, config); BaseSound.call(this, manager, key, config);
@ -240,6 +255,19 @@ var HTML5AudioSound = new Class({
if (this.audio) { if (this.audio) {
this.audio.playbackRate = this.totalRate; this.audio.playbackRate = this.totalRate;
} }
},
checkTouchLocked: function (type, name, value) {
if (this.manager.touchLocked) {
this.touchLockedActionQueue.push({
sound: this,
type: type,
name: name,
value: value,
time: window.performance.now()
});
return true;
}
return false;
} }
}); });
/** /**