Skip to content

Commit f510f71

Browse files
Implemented unlock method for HTML5AudioSoundManager class
1 parent 4ca73ae commit f510f71

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

src/sound/html5/HTML5AudioSoundManager.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,23 @@ var HTML5AudioSoundManager = new Class({
7171
this.sounds.push(sound);
7272
return sound;
7373
},
74+
unlock: function () {
75+
var _this = this;
76+
if ('ontouchstart' in window) {
77+
var unlock_1 = function () {
78+
document.body.removeEventListener('touchstart', unlock_1);
79+
document.body.removeEventListener('touchend', unlock_1);
80+
_this.game.cache.audio.entries.each(function (key, tags) {
81+
for (var i = 0; i < tags.length; i++) {
82+
tags[i].load();
83+
}
84+
return true;
85+
});
86+
};
87+
document.body.addEventListener('touchstart', unlock_1, false);
88+
document.body.addEventListener('touchend', unlock_1, false);
89+
}
90+
},
7491
onBlur: function () {
7592
this.forEachActiveSound(function (sound) {
7693
if (sound.isPlaying) {

0 commit comments

Comments
 (0)