SOUND_ON_ALARM still doesn't work
SOUND_ON_ALARM still doesn't work
I've had trouble getting this to work since 1.30.4
My 'ZM_DIR_SOUNDS' directory equals 'sounds'. I'm not sure if that means it should be relative to ZM's root or my apache web server's root? (/var/www/html/) But I have a directory called 'sounds' in both and it still does not play any sound.
I have seen lots of other people with issue getting this working too so I'm wondering if someone with it actually working can share their config options.
My 'ZM_DIR_SOUNDS' directory equals 'sounds'. I'm not sure if that means it should be relative to ZM's root or my apache web server's root? (/var/www/html/) But I have a directory called 'sounds' in both and it still does not play any sound.
I have seen lots of other people with issue getting this working too so I'm wondering if someone with it actually working can share their config options.
- bkjaya1952
- Posts: 282
- Joined: Sat Aug 25, 2018 3:24 pm
- Location: Sri Lanka
Re: SOUND_ON_ALARM still doesn't work
Please try the method used in the following link
https://bkjaya.wordpress.com/2020/11/08 ... -a-motion/
https://bkjaya.wordpress.com/2020/11/08 ... -a-motion/
Re: SOUND_ON_ALARM still doesn't work
interesting. thanks for posting
just to clarify:
the sound is being played on the zoneminder server. not thru the zoneminder web interface ?
my server is in the basement but having the zoneminder webpage popup with a sound would be cool.
just to clarify:
the sound is being played on the zoneminder server. not thru the zoneminder web interface ?
my server is in the basement but having the zoneminder webpage popup with a sound would be cool.
Re: SOUND_ON_ALARM still doesn't work
Yeah that would be a server-side beep rather than through the client you're viewing from. I did something similar before but need something to play on my laptop when I'm away from home.
The hack I'm using currently utilizes Web Sound API...
Then I just edit the rest of the javascript in 'views/js/montag.js' to run the 'beep' function...
So instead of...
I have...
Which works (in Chrome at least) but is clunky and I don't like having to redo it every time ZM updates or upgrades.
The hack I'm using currently utilizes Web Sound API...
Code: Select all
//Make a beep function with the new Web Sound API
var audioContext = AudioContext && new AudioContext();
function beep(amp, freq, ms){//amp:0..100, freq in Hz, ms
if (!audioContext) return;
var osc = audioContext.createOscillator();
var gain = audioContext.createGain();
osc.connect(gain);
osc.value = freq;
gain.connect(audioContext.destination);
gain.gain.value = amp/100;
osc.start(audioContext.currentTime);
osc.stop(audioContext.currentTime+ms/1000);
}
So instead of...
Code: Select all
if ( false && SOUND_ON_ALARM )
{
// Enable the alarm sound
$('alarmSound').removeClass( 'hidden' );
}
Code: Select all
if ( SOUND_ON_ALARM ) {
// Enable the alarm sound
//Use our new beep function instead
beep(25,750,500);
}
Re: SOUND_ON_ALARM still doesn't work
thanks for the response. I need to get eventserver going before I start making a bunch of noise in my living room . Headlights from cars coming down the street at night are an issue I havent resolved yet even using preclusive zones.
for my use case this got me thinking just to modify bkjaya1952 example and have the server ssh via public keys to my linux box in the living room and play the sound. then it would be independent of even the browser. In your case as a road warrior / laptop it probably wouldnt work as well
EDIT - yea my ssh idea was a little more involved. Had to allow the www-data user to ssh to the computer in the living room using public keys.
so in zoneminder the filter called this local bash script which ran a remote script to create the sound in my living room ( yea the sound is barking dogs )
yes had to use ssh-keygen and ssh-copy-id and change permissions on the new key dir to allow this to happen.
and this snippet helped a lot for debugging as I wasnt able to get debugging working with zmfilter.pl. the issue was probably at my end. you would need a different filter_id
and for completeness the script that actually plays the dog barking sound. yes I play it 3 times cause pulse audio will sometimes miss the first one if it is currently idle
for my use case this got me thinking just to modify bkjaya1952 example and have the server ssh via public keys to my linux box in the living room and play the sound. then it would be independent of even the browser. In your case as a road warrior / laptop it probably wouldnt work as well
EDIT - yea my ssh idea was a little more involved. Had to allow the www-data user to ssh to the computer in the living room using public keys.
so in zoneminder the filter called this local bash script which ran a remote script to create the sound in my living room ( yea the sound is barking dogs )
Code: Select all
ssh -o StrictHostKeyChecking=no -i /home/user/zoneminder_keys/id_rsa_zoneminder remote_user@living_room '/home/remote_user/barkme.sh &>/dev/null'
and this snippet helped a lot for debugging as I wasnt able to get debugging working with zmfilter.pl. the issue was probably at my end. you would need a different filter_id
Code: Select all
sudo su -l www-data -s /bin/bash -c ' /usr/bin/perl -wT /usr/bin/zmfilter.pl --filter_id=37'
Code: Select all
#!/bin/bash
for each in 1 2 3;do $(aplay bark.wav );done
Last edited by jperkins on Tue Feb 16, 2021 1:35 am, edited 1 time in total.
Re: SOUND_ON_ALARM still doesn't work
Heh that's one way to get it done. Yeah unfortunately that won't work for my situation though because my biggest need for having an alert sound is when I'm away from home, so no way to predict what host SSH would need to connect to unless I setup a dynamic DNS script at all the places I go, and I have a feeling most won't let me do that lol
That's funny with the dogs... Maybe you could have the zone by your back door or windows play a shotgun racking sound haha
Yeah I had that problem with headlights too. What I found worked really well in that situation was setting the preclusive zone on a highly reflective area of the zone. For me, it's on the white-paint of my window sil. I noticed it was lighting up way before any of the other parts of the zone when cars were still very far away. So I set the preclusive zone on that spot and it cut the false alarms way down. If you can't find a reflective spot like that while analyzing the videos, you could even hang something reflective up to catch the light and then paint the preclusive zone on that in ZM.
That's funny with the dogs... Maybe you could have the zone by your back door or windows play a shotgun racking sound haha
Yeah I had that problem with headlights too. What I found worked really well in that situation was setting the preclusive zone on a highly reflective area of the zone. For me, it's on the white-paint of my window sil. I noticed it was lighting up way before any of the other parts of the zone when cars were still very far away. So I set the preclusive zone on that spot and it cut the false alarms way down. If you can't find a reflective spot like that while analyzing the videos, you could even hang something reflective up to catch the light and then paint the preclusive zone on that in ZM.
Re: SOUND_ON_ALARM still doesn't work
I tried this solution and it doesn’t seem to work. I can run the mpg123 command from terminal and sound plays fine but when try and have the command run when the filter is executed no sound is played.bkjaya1952 wrote: ↑Mon Feb 15, 2021 6:02 am Please try the method used in the following link
https://bkjaya.wordpress.com/2020/11/08 ... -a-motion/
I can’t get my head around the fact that ZM has built in support for sound alerts but it doesn’t work
Re: SOUND_ON_ALARM still doesn't work
I think it might be kind of a niche feature and there's probably a lot of issues with browser compatibility. I've read somewhere that it actually works in Internet Explorer.Flumpy wrote: ↑Mon Mar 08, 2021 4:13 pmI tried this solution and it doesn’t seem to work. I can run the mpg123 command from terminal and sound plays fine but when try and have the command run when the filter is executed no sound is played.bkjaya1952 wrote: ↑Mon Feb 15, 2021 6:02 am Please try the method used in the following link
https://bkjaya.wordpress.com/2020/11/08 ... -a-motion/
I can’t get my head around the fact that ZM has built in support for sound alerts but it doesn’t work
I've been meaning to just offer up the 'Web Sound API' hack I figured out as a custom skin in 'User Contributions' since all the modifications necessary are only against the skin files.
Re: SOUND_ON_ALARM still doesn't work
I am using a raspberry PI with Firefox but could try internet explorer on windows laptop to see if that works. I did discover that on Firefox when using developer tools that the webpage was loading the mp3 file so it’s definitely been recognised in the webpage coding but it doesn’t do anything with it when a motion is detected. I’ll have a try with the web sound API hack and see how I get onkennbr34 wrote: ↑Tue Mar 09, 2021 2:35 pmI think it might be kind of a niche feature and there's probably a lot of issues with browser compatibility. I've read somewhere that it actually works in Internet Explorer.Flumpy wrote: ↑Mon Mar 08, 2021 4:13 pmI tried this solution and it doesn’t seem to work. I can run the mpg123 command from terminal and sound plays fine but when try and have the command run when the filter is executed no sound is played.bkjaya1952 wrote: ↑Mon Feb 15, 2021 6:02 am Please try the method used in the following link
https://bkjaya.wordpress.com/2020/11/08 ... -a-motion/
I can’t get my head around the fact that ZM has built in support for sound alerts but it doesn’t work
I've been meaning to just offer up the 'Web Sound API' hack I figured out as a custom skin in 'User Contributions' since all the modifications necessary are only against the skin files.
Re: SOUND_ON_ALARM still doesn't work
I have tried the websound API hack with no success, so I tried the following code :-Flumpy wrote: ↑Tue Mar 09, 2021 4:10 pmI am using a raspberry PI with Firefox but could try internet explorer on windows laptop to see if that works. I did discover that on Firefox when using developer tools that the webpage was loading the mp3 file so it’s definitely been recognised in the webpage coding but it doesn’t do anything with it when a motion is detected. I’ll have a try with the web sound API hack and see how I get onkennbr34 wrote: ↑Tue Mar 09, 2021 2:35 pmI think it might be kind of a niche feature and there's probably a lot of issues with browser compatibility. I've read somewhere that it actually works in Internet Explorer.Flumpy wrote: ↑Mon Mar 08, 2021 4:13 pm
I tried this solution and it doesn’t seem to work. I can run the mpg123 command from terminal and sound plays fine but when try and have the command run when the filter is executed no sound is played.
I can’t get my head around the fact that ZM has built in support for sound alerts but it doesn’t work
I've been meaning to just offer up the 'Web Sound API' hack I figured out as a custom skin in 'User Contributions' since all the modifications necessary are only against the skin files.
Code: Select all
if ( newAlarm ) {
var audioElement = document.createElement('audio');
audioElement.setAttribute('src', '/sounds/tarzan.ogg');
audioElement.load()
audioElement.addEventListener("canplay", function() {
audioElement.play();
}, true);
alert('play');
if ( POPUP_ON_ALARM ) {
windowToFront();
}
}
- bkjaya1952
- Posts: 282
- Joined: Sat Aug 25, 2018 3:24 pm
- Location: Sri Lanka
Re: SOUND_ON_ALARM still doesn't work
Please try
sudo chown -R www-data:www-data /usr/share/zoneminder/www/sounds/alarm.mp3
sudo chown -R www-data:www-data /usr/share/zoneminder/www/sounds/alarm.mp3
Re: SOUND_ON_ALARM still doesn't work
Sorry not to side-track the issue, but what browser is the windowToFront() method working for you in?Flumpy wrote: ↑Tue Mar 09, 2021 9:42 pmI have tried the websound API hack with no success, so I tried the following code :-Flumpy wrote: ↑Tue Mar 09, 2021 4:10 pmI am using a raspberry PI with Firefox but could try internet explorer on windows laptop to see if that works. I did discover that on Firefox when using developer tools that the webpage was loading the mp3 file so it’s definitely been recognised in the webpage coding but it doesn’t do anything with it when a motion is detected. I’ll have a try with the web sound API hack and see how I get onkennbr34 wrote: ↑Tue Mar 09, 2021 2:35 pm
I think it might be kind of a niche feature and there's probably a lot of issues with browser compatibility. I've read somewhere that it actually works in Internet Explorer.
I've been meaning to just offer up the 'Web Sound API' hack I figured out as a custom skin in 'User Contributions' since all the modifications necessary are only against the skin files.
The alert pop up works with no problems when alarm status is activated but the sound doesn't play. I have tried various Firefox,Edge and Chrome browser and none played the sound. I feel I'm so close to resolving this one, if I have any success will feed back how I managed it.Code: Select all
if ( newAlarm ) { var audioElement = document.createElement('audio'); audioElement.setAttribute('src', '/sounds/tarzan.ogg'); audioElement.load() audioElement.addEventListener("canplay", function() { audioElement.play(); }, true); alert('play'); if ( POPUP_ON_ALARM ) { windowToFront(); } }
That's unforatune the Web Sound API didn't work. It worked for me in Firefox and Chrome, but I'm also only using it on Linux desktops, no Windows.
Re: SOUND_ON_ALARM still doesn't work
I’ve not really done anything with the windowToFront method so don’t know what browsers it works in. The sound is now ok with the code I posted earlier once realised the path to the sound file was incorrect!kennbr34 wrote: ↑Wed Mar 10, 2021 10:10 amSorry not to side-track the issue, but what browser is the windowToFront() method working for you in?Flumpy wrote: ↑Tue Mar 09, 2021 9:42 pmI have tried the websound API hack with no success, so I tried the following code :-Flumpy wrote: ↑Tue Mar 09, 2021 4:10 pm
I am using a raspberry PI with Firefox but could try internet explorer on windows laptop to see if that works. I did discover that on Firefox when using developer tools that the webpage was loading the mp3 file so it’s definitely been recognised in the webpage coding but it doesn’t do anything with it when a motion is detected. I’ll have a try with the web sound API hack and see how I get on
The alert pop up works with no problems when alarm status is activated but the sound doesn't play. I have tried various Firefox,Edge and Chrome browser and none played the sound. I feel I'm so close to resolving this one, if I have any success will feed back how I managed it.Code: Select all
if ( newAlarm ) { var audioElement = document.createElement('audio'); audioElement.setAttribute('src', '/sounds/tarzan.ogg'); audioElement.load() audioElement.addEventListener("canplay", function() { audioElement.play(); }, true); alert('play'); if ( POPUP_ON_ALARM ) { windowToFront(); } }
That's unforatune the Web Sound API didn't work. It worked for me in Firefox and Chrome, but I'm also only using it on Linux desktops, no Windows.
- bkjaya1952
- Posts: 282
- Joined: Sat Aug 25, 2018 3:24 pm
- Location: Sri Lanka
Re: SOUND_ON_ALARM still doesn't work
Please refer the following link https://bkjaya.wordpress.com/2020/11/08 ... -a-motion/ & try the following steps on the Ubuntu terminal
sudo chmod +x /usr/share/zoneminder/www/sounds/alarm.mp3
sudo vsudo
Then add the following line to the opened file and save
ALL ALL = (root) NOPASSWD: /usr/share/zoneminder/www/sounds/alarm.mp3
sudo chmod +x /usr/share/zoneminder/www/sounds/alarm.mp3
sudo vsudo
Then add the following line to the opened file and save
ALL ALL = (root) NOPASSWD: /usr/share/zoneminder/www/sounds/alarm.mp3