Browse Source

Added more sound options and moved them to separate section in settings.

pull/162/head
Simon Eisenmann 11 years ago
parent
commit
215408598a
  1. 7
      static/js/controllers/appcontroller.js
  2. 19
      static/js/controllers/uicontroller.js
  3. 2
      static/js/directives/chat.js
  4. 32
      static/js/services/playsound.js
  5. 33
      static/partials/settings.html

7
static/js/controllers/appcontroller.js

@ -56,7 +56,11 @@ define(["jquery", "angular", "underscore"], function($, angular, _) { @@ -56,7 +56,11 @@ define(["jquery", "angular", "underscore"], function($, angular, _) {
videoLeakyBucket: true,
videoNoiseReduction: false
},
playSoundEffects: true
sound: {
incomingMessages: true,
incomingCall: true,
roomJoinLeave: false
}
}
};
$scope.master = angular.copy($scope.defaults);
@ -67,6 +71,7 @@ define(["jquery", "angular", "underscore"], function($, angular, _) { @@ -67,6 +71,7 @@ define(["jquery", "angular", "underscore"], function($, angular, _) {
$scope.updateStatus();
}
$scope.refreshWebrtcSettings();
$scope.refreshSoundSettings();
};
$scope.reset = function() {

19
static/js/controllers/uicontroller.js

@ -88,7 +88,8 @@ define(['jquery', 'underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'web @@ -88,7 +88,8 @@ define(['jquery', 'underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'web
"end": "end1",
"dial": "ringtone1",
"connect": "connect1",
"prompt": "question1"
"prompt": "question1",
"chatmessage": "message1"
});
var displayName = safeDisplayName;
@ -164,6 +165,16 @@ define(['jquery', 'underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'web @@ -164,6 +165,16 @@ define(['jquery', 'underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'web
};
$scope.refreshWebrtcSettings(); // Call once for bootstrap.
$scope.refreshSoundSettings = function() {
var s = $scope.master.settings.sound;
playSound.disable("chatmessage", !s.incomingMessages);
playSound.disable("ring", !s.incomingCall);
var roomJoinLeave = $scope.peer ? false : s.roomJoinLeave; // Do not play these sounds when in call.
playSound.disable("joined", !roomJoinLeave);
playSound.disable("left", !roomJoinLeave);
};
$scope.refreshSoundSettings(); // Call once on bootstrap;
var pickupTimeout = null;
var autoAcceptTimeout = null;
$scope.updateAutoAccept = function(id, from) {
@ -235,12 +246,10 @@ define(['jquery', 'underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'web @@ -235,12 +246,10 @@ define(['jquery', 'underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'web
// Watch for peer and disable some sounds while there is a peer.
if (c && !o) {
// New call.
playSound.disable("joined");
playSound.disable("left");
$scope.refreshSoundSettings();
} else if (!c && o) {
// No longer in call.
playSound.disable("joined", false);
playSound.disable("left", false);
$scope.refreshSoundSettings();
}
});

2
static/js/directives/chat.js

@ -383,7 +383,7 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro @@ -383,7 +383,7 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
// Make sure we are not in group chat or the message is from ourselves
// before we beep and shout.
if (!subscope.isgroupchat && from !== sessionid) {
playSound.play("message1");
playSound.play("chatmessage");
desktopNotify.notify(translation._("Message from ") + displayName(from), message);
appData.e.triggerHandler("uiNotification", ["chatmessage", {from: from, message: message, first: subscope.firstmessage}]);
}

32
static/js/services/playsound.js

@ -28,7 +28,7 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) { @@ -28,7 +28,7 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) {
window.PLAYSOUND = registry; // make available for debug.
// playSound
return ["appData", function(appData) {
return [function() {
var SoundInterval = function(sound, id, time) {
this.sound = sound;
@ -112,17 +112,14 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) { @@ -112,17 +112,14 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) {
};
Sound.prototype.play = function(id, interval, autostart) {
Sound.prototype.play = function(name, interval, autostart) {
if (!this.sound) {
console.log("Play sound but not initialized.", id);
return null;
}
if (!this.shouldPlaySound(id)) {
console.log("Play sound but not initialized.", name);
return null;
}
id = this.getId(id);
var id = this.getId(name);
if (interval) {
@ -137,6 +134,10 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) { @@ -137,6 +134,10 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) {
} else {
if (!this.shouldPlaySound(name) || !this.shouldPlaySound(id)) {
return;
}
var player = this.players[id];
var sound = this.sound;
if (!player) {
@ -162,11 +163,10 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) { @@ -162,11 +163,10 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) {
};
Sound.prototype.shouldPlaySound = function(id) {
if (disabled.hasOwnProperty(id) && disabled[id] >= 1) {
if (disabled.all || disabled.hasOwnProperty(id)) {
return false;
}
var data = appData.get();
return data && data.master.settings.playSoundEffects;
return true;
};
return {
@ -204,19 +204,9 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) { @@ -204,19 +204,9 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) {
return s.play(id, time);
},
disable: function(id, status) {
// Disable play back of a certain sound id. Pass status as false to re-enable.
if (!disabled.hasOwnProperty(id)) {
disabled[id] = 0;
}
if (status !== false) {
// Increment for disable.
disabled[id]++;
disabled[id] = true;
} else {
// Decrement for eenable.
disabled[id]--;
}
if (disabled[id] === 0) {
// Cleanup when 0.
delete disabled[id];
}
}

33
static/partials/settings.html

@ -110,16 +110,7 @@ @@ -110,16 +110,7 @@
<span class="help-block">{{_('Set alternative room to join at start.')}}</span>
</div>
</div>
<div class="form-group">
<label class="col-xs-4 control-label">{{_('Notification sounds')}}</label>
<div class="col-xs-8">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="user.settings.playSoundEffects"/>&nbsp;
</label>
</div>
</div>
</div>
<legend>{{_('Notifications')}}</legend>
<div class="form-group" ng-show="desktopNotify.supported">
<label class="col-xs-4 control-label">{{_('Desktop notification')}}</label>
<div class="col-xs-8">
@ -130,6 +121,24 @@ @@ -130,6 +121,24 @@
</span>
</div>
</div>
<div class="form-group">
<label class="col-xs-4 control-label"><input type="checkbox" ng-model="user.settings.sound.incomingMessages"/></label>
<div class="col-xs-8">
<div class="form-control-static">{{_('Sounds for incoming messages')}}</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-4 control-label"><input type="checkbox" ng-model="user.settings.sound.incomingCall"/></label>
<div class="col-xs-8">
<div class="form-control-static">{{_('Ring on incoming calls')}}</div>
</div>
</div>
<div class="form-group">
<label class="col-xs-4 control-label"><input type="checkbox" ng-model="user.settings.sound.roomJoinLeave"/></label>
<div class="col-xs-8">
<div class="form-control-static">{{_('Sounds for users in current room')}}</div>
</div>
</div>
</settings-settings>
<settings-extra settings-extra></settings-extra>
@ -268,8 +277,10 @@ @@ -268,8 +277,10 @@
</settings-advanced>
<hr/>
<div class="form-group">
<div class="col-xs-4 control-label"></div>
<div class="col-xs-4 control-label"></div>
<div class="col-xs-8">
<a ng-click="showAdvancedSettings = !showAdvancedSettings"><span ng-show="showAdvancedSettings">{{_('Show advanced settings')}}</span><span ng-hide="showAdvancedSettings">{{_('Hide advanced settings')}}</span></a>
</div>

Loading…
Cancel
Save