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, _) {
audioTypingNoiseDetection: true, audioTypingNoiseDetection: true,
videoLeakyBucket: true, videoLeakyBucket: true,
videoNoiseReduction: false videoNoiseReduction: false
} },
playSoundEffects: true
} }
}; };
$scope.master = angular.copy($scope.defaults); $scope.master = angular.copy($scope.defaults);

15
static/js/services/playsound.js

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

13
static/partials/settings.html

@ -265,6 +265,19 @@
</div> </div>
</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/> <hr/>
<div class="form-group"> <div class="form-group">

Loading…
Cancel
Save