2018-01-08 18:25:11 +00:00
|
|
|
var Class = require('../../utils/Class');
|
|
|
|
var BaseSoundManager = require('../BaseSoundManager');
|
2018-01-08 18:26:32 +00:00
|
|
|
var HTML5AudioSound = require('./HTML5AudioSound');
|
2018-01-08 18:25:11 +00:00
|
|
|
var HTML5AudioSoundManager = new Class({
|
|
|
|
Extends: BaseSoundManager,
|
|
|
|
initialize: function HTML5AudioSoundManager(game) {
|
2018-01-08 18:27:44 +00:00
|
|
|
this.onBlurPausedSounds = [];
|
2018-01-08 18:25:11 +00:00
|
|
|
BaseSoundManager.call(this, game);
|
2018-01-08 18:26:32 +00:00
|
|
|
},
|
|
|
|
add: function (key, config) {
|
|
|
|
var sound = new HTML5AudioSound(this, key, config);
|
|
|
|
this.sounds.push(sound);
|
|
|
|
return sound;
|
2018-01-08 18:28:21 +00:00
|
|
|
},
|
|
|
|
onBlur: function () {
|
|
|
|
this.forEachActiveSound(function (sound) {
|
|
|
|
if (sound.isPlaying) {
|
|
|
|
this.onBlurPausedSounds.push(sound);
|
|
|
|
sound.pause();
|
|
|
|
}
|
|
|
|
});
|
2018-01-08 18:25:11 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
module.exports = HTML5AudioSoundManager;
|