17.12.2019, 16:50
I use the custom Javascript below to play an audio file (doorbell).
Unfortunately it will not work cross browser since the play function isn't allowed from script any longer for Safari (IOS) and Firefox. Only in Chrome it's still working so far.
Does any of you know a better solution to play audio from a simple Javascript?
$(function() {
if (typeof grp != 'undefined') {
grp.listen('4/1/1', function(object, state) {
if (state == 'value') {
var myaudio = new Audio('https://knxgroep.nl/plugins/deurbel.mp3');
myaudio.play();
}
}, true);
}
});
Unfortunately it will not work cross browser since the play function isn't allowed from script any longer for Safari (IOS) and Firefox. Only in Chrome it's still working so far.
Does any of you know a better solution to play audio from a simple Javascript?
$(function() {
if (typeof grp != 'undefined') {
grp.listen('4/1/1', function(object, state) {
if (state == 'value') {
var myaudio = new Audio('https://knxgroep.nl/plugins/deurbel.mp3');
myaudio.play();
}
}, true);
}
});