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

19
static/js/controllers/uicontroller.js

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

2
static/js/directives/chat.js

@ -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 // Make sure we are not in group chat or the message is from ourselves
// before we beep and shout. // before we beep and shout.
if (!subscope.isgroupchat && from !== sessionid) { if (!subscope.isgroupchat && from !== sessionid) {
playSound.play("message1"); playSound.play("chatmessage");
desktopNotify.notify(translation._("Message from ") + displayName(from), message); desktopNotify.notify(translation._("Message from ") + displayName(from), message);
appData.e.triggerHandler("uiNotification", ["chatmessage", {from: from, message: message, first: subscope.firstmessage}]); 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) {
window.PLAYSOUND = registry; // make available for debug. window.PLAYSOUND = registry; // make available for debug.
// playSound // playSound
return ["appData", function(appData) { return [function() {
var SoundInterval = function(sound, id, time) { var SoundInterval = function(sound, id, time) {
this.sound = sound; this.sound = sound;
@ -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) { if (!this.sound) {
console.log("Play sound but not initialized.", id); console.log("Play sound but not initialized.", name);
return null;
}
if (!this.shouldPlaySound(id)) {
return null; return null;
} }
id = this.getId(id); var id = this.getId(name);
if (interval) { if (interval) {
@ -137,6 +134,10 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) {
} else { } else {
if (!this.shouldPlaySound(name) || !this.shouldPlaySound(id)) {
return;
}
var player = this.players[id]; var player = this.players[id];
var sound = this.sound; var sound = this.sound;
if (!player) { if (!player) {
@ -162,11 +163,10 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) {
}; };
Sound.prototype.shouldPlaySound = function(id) { Sound.prototype.shouldPlaySound = function(id) {
if (disabled.hasOwnProperty(id) && disabled[id] >= 1) { if (disabled.all || disabled.hasOwnProperty(id)) {
return false; return false;
} }
var data = appData.get(); return true;
return data && data.master.settings.playSoundEffects;
}; };
return { return {
@ -204,19 +204,9 @@ define(['underscore', 'Howler', 'require'], function(_, Howler, require) {
return s.play(id, time); return s.play(id, time);
}, },
disable: function(id, status) { 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) { if (status !== false) {
// Increment for disable. disabled[id] = true;
disabled[id]++;
} else { } else {
// Decrement for eenable.
disabled[id]--;
}
if (disabled[id] === 0) {
// Cleanup when 0.
delete disabled[id]; delete disabled[id];
} }
} }

33
static/partials/settings.html

@ -110,16 +110,7 @@
<span class="help-block">{{_('Set alternative room to join at start.')}}</span> <span class="help-block">{{_('Set alternative room to join at start.')}}</span>
</div> </div>
</div> </div>
<div class="form-group"> <legend>{{_('Notifications')}}</legend>
<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>
<div class="form-group" ng-show="desktopNotify.supported"> <div class="form-group" ng-show="desktopNotify.supported">
<label class="col-xs-4 control-label">{{_('Desktop notification')}}</label> <label class="col-xs-4 control-label">{{_('Desktop notification')}}</label>
<div class="col-xs-8"> <div class="col-xs-8">
@ -130,6 +121,24 @@
</span> </span>
</div> </div>
</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-settings>
<settings-extra settings-extra></settings-extra> <settings-extra settings-extra></settings-extra>
@ -268,8 +277,10 @@
</settings-advanced> </settings-advanced>
<hr/>
<div class="form-group"> <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"> <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> <a ng-click="showAdvancedSettings = !showAdvancedSettings"><span ng-show="showAdvancedSettings">{{_('Show advanced settings')}}</span><span ng-hide="showAdvancedSettings">{{_('Hide advanced settings')}}</span></a>
</div> </div>

Loading…
Cancel
Save