|
|
@ -5,31 +5,30 @@ define('sounds', ['buzz'], function(buzz) {
|
|
|
|
var Sounds = {};
|
|
|
|
var Sounds = {};
|
|
|
|
|
|
|
|
|
|
|
|
var loadedSounds = {};
|
|
|
|
var loadedSounds = {};
|
|
|
|
var eventSoundMapping = {};
|
|
|
|
var eventSoundMapping;
|
|
|
|
var files = {};
|
|
|
|
var files;
|
|
|
|
|
|
|
|
|
|
|
|
loadFiles();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
loadMapping();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
socket.on('event:sounds.reloadMapping', loadMapping);
|
|
|
|
socket.on('event:sounds.reloadMapping', loadMapping);
|
|
|
|
|
|
|
|
|
|
|
|
function loadFiles() {
|
|
|
|
function loadMapping(callback) {
|
|
|
|
socket.emit('modules.sounds.getSounds', function(err, sounds) {
|
|
|
|
callback = callback || function() {};
|
|
|
|
|
|
|
|
socket.emit('modules.sounds.getMapping', function(err, mapping) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
return app.alertError('[sounds] Could not initialise!');
|
|
|
|
return app.alertError('[sounds] Could not load sound mapping!');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
eventSoundMapping = mapping;
|
|
|
|
files = sounds;
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function loadMapping() {
|
|
|
|
function loadData(callback) {
|
|
|
|
socket.emit('modules.sounds.getMapping', function(err, mapping) {
|
|
|
|
socket.emit('modules.sounds.getData', function(err, data) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
|
return app.alertError('[sounds] Could not load sound mapping!');
|
|
|
|
return app.alertError('[sounds] Could not load sound mapping!');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
eventSoundMapping = mapping;
|
|
|
|
eventSoundMapping = data.mapping;
|
|
|
|
|
|
|
|
files = data.files;
|
|
|
|
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -38,22 +37,37 @@ define('sounds', ['buzz'], function(buzz) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function loadFile(fileName, callback) {
|
|
|
|
function loadFile(fileName, callback) {
|
|
|
|
|
|
|
|
function createSound() {
|
|
|
|
|
|
|
|
if (files && files[fileName]) {
|
|
|
|
|
|
|
|
loadedSounds[fileName] = new buzz.sound(files[fileName]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
callback();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (isSoundLoaded(fileName)) {
|
|
|
|
if (isSoundLoaded(fileName)) {
|
|
|
|
return callback();
|
|
|
|
return callback();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (files && files[fileName]) {
|
|
|
|
if (!files || !files[fileName]) {
|
|
|
|
loadedSounds[fileName] = new buzz.sound(files[fileName]);
|
|
|
|
return loadData(createSound);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
callback();
|
|
|
|
createSound();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Sounds.play = function(name) {
|
|
|
|
Sounds.play = function(name) {
|
|
|
|
|
|
|
|
function play() {
|
|
|
|
|
|
|
|
Sounds.playFile(eventSoundMapping[name]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!config.notificationSounds) {
|
|
|
|
if (!config.notificationSounds) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Sounds.playFile(eventSoundMapping[name]);
|
|
|
|
if (!eventSoundMapping) {
|
|
|
|
|
|
|
|
return loadData(play);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
play();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Sounds.playFile = function(fileName) {
|
|
|
|
Sounds.playFile = function(fileName) {
|
|
|
|