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