Browse Source

Merge pull request #208 from theurere/disable-sound-setting

Settings option to control app sounds
pull/217/head
Simon Eisenmann 11 years ago
parent
commit
be26aea188
  1. 3
      static/js/controllers/appcontroller.js
  2. 15
      static/js/services/playsound.js
  3. 13
      static/partials/settings.html

3
static/js/controllers/appcontroller.js

@ -55,7 +55,8 @@ define(["jquery", "angular", "underscore"], function($, angular, _) { @@ -55,7 +55,8 @@ define(["jquery", "angular", "underscore"], function($, angular, _) {
audioTypingNoiseDetection: true,
videoLeakyBucket: true,
videoNoiseReduction: false
}
},
playSoundEffects: true
}
};
$scope.master = angular.copy($scope.defaults);

15
static/js/services/playsound.js

@ -22,6 +22,9 @@ @@ -22,6 +22,9 @@
"use strict";
define(['underscore', 'Howler', 'require'], function(_, Howler, require) {
// playSound
return ["appData", function(appData) {
var SoundInterval = function(sound, id, time) {
this.sound = sound;
this.id = id;
@ -104,13 +107,15 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) { @@ -104,13 +107,15 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) {
};
Sound.prototype.play = function(id, interval, autostart) {
if (!this.sound) {
console.log("Play sound but not initialized.", id);
return null;
}
if (!this.shouldPlaySound(id)) {
return;
}
id = this.getId(id);
@ -151,13 +156,15 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) { @@ -151,13 +156,15 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) {
};
Sound.prototype.shouldPlaySound = function (id) {
var data = appData.get();
return data && data.master.settings.playSoundEffects;
};
// Active initialized sound instances are kept here.
var registry = {};
window.PLAYSOUND = registry; // make available for debug.
// playSound
return [function() {
return {
initialize: function(options, name, aliases) {
if (!name) {

13
static/partials/settings.html

@ -265,6 +265,19 @@ @@ -265,6 +265,19 @@
</div>
</div>
<div>
<legend>{{_('Sound effects')}}</legend>
<div class="form-group">
<div class="col-xs-8 col-xs-offset-4">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="user.settings.playSoundEffects"> {{_('Play Sound Effects')}}
</label>
</div>
</div>
</div>
</div>
<hr/>
<div class="form-group">

Loading…
Cancel
Save