Merge pull request #194 from matrix-org/audio_notifications

Make audio notifications work
pull/21833/head
David Baker 2016-03-04 18:24:01 +00:00
commit 052925d95b
1 changed files with 17 additions and 9 deletions

View File

@ -35,7 +35,7 @@ var Notifier = {
return TextForEvent.textForEvent(ev);
},
displayNotification: function(ev, room) {
displayNotification: function(ev, room, actions) {
if (!global.Notification || global.Notification.permission != 'granted') {
return;
}
@ -83,12 +83,20 @@ var Notifier = {
});
global.focus();
};
/*var audioClip;
if (audioNotification) {
audioClip = playAudio(audioNotification);
}*/
var playAudio = function() {
var e = document.getElementById("messageAudio");
if (e) {
e.load();
e.play();
return e;
}
};
var audioClip;
if (actions.tweaks.sound) {
audioClip = playAudio();
}
global.setTimeout(function() {
notification.close();
@ -198,7 +206,7 @@ var Notifier = {
var actions = MatrixClientPeg.get().getPushActionsForEvent(ev);
if (actions && actions.notify) {
this.displayNotification(ev, room);
this.displayNotification(ev, room, actions);
}
}
};
@ -207,4 +215,4 @@ if (!global.mxNotifier) {
global.mxNotifier = Notifier;
}
module.exports = global.mxNotifier;
module.exports = global.mxNotifier;