Options -> Web -> WEB_SOUND_ON_ALARM

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
RonRN18
Posts: 58
Joined: Tue Aug 13, 2019 1:00 am

Options -> Web -> WEB_SOUND_ON_ALARM

Post by RonRN18 »

I'm not sure if I just don't understand how this works or if this feature actually does work. I have enabled the option and then tried to find the "sounds" directory. I did a bunch of searching and the only "sounds" folder I could find was at /usr/share/sounds. In this directory, I saw several sub-directories that had several different sound effects. I initially thought this was what it was looking for, but it would not trigger any sounds. I then searched around and saw this post, and saw the suggestion to modify the zm.conf file. There was no mention of a ZM_DIR_SOUNDS directory anywhere, so I created a new entry in the configuration file... I wasn't sure if it was looking for a relative or a specific directory location. If it were relative, I'd think it relative to the "www" directory, I create a sub-directory to "www" and set the "ZM_DIR_SOUNDS=sounds". That didn't work. I then tried to put in the long name and changed it to "ZM_DIR_SOUNDS=/usr/share/zoneminder/www/sounds" but that doesn't work either. I've tried all I could think of and hoping someone here could steer me right.
Simpler
Posts: 77
Joined: Mon Nov 02, 2015 12:40 am

Re: Options -> Web -> WEB_SOUND_ON_ALARM

Post by Simpler »

I also can't get this to work.

I've toggled on WEB_SOUND_ON_ALARM (from Options -> Web) and I've specified an WEB_ALARM_SOUND file as a .ogg file that is in the www/sounds directory. I've even tested that the sound plays on the web if I enter

Code: Select all

http://localhost/zm/sounds/Soft_Airy_Swish.ogg
as the URL.

Does anyone have this working?

I'm on 1.36.33.

Thanks
User avatar
iconnor
Posts: 3356
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Options -> Web -> WEB_SOUND_ON_ALARM

Post by iconnor »

I once had this working but it was very inconsistent across browsers and browsers have gotten more complicated since then. I'll try to find some time to revisit this and post back here.
Simpler
Posts: 77
Joined: Mon Nov 02, 2015 12:40 am

Re: Options -> Web -> WEB_SOUND_ON_ALARM

Post by Simpler »

Hi Isaac,

Thanks for the reply.

I created a pull request to address this issue.

Check it out here.
User avatar
iconnor
Posts: 3356
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Options -> Web -> WEB_SOUND_ON_ALARM

Post by iconnor »

Merged, thanks so much. I'll get it into 1.36.34 as well.
dougmccrary
Posts: 1373
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: Options -> Web -> WEB_SOUND_ON_ALARM

Post by dougmccrary »

I see 1.36.34 in proposed ppa, but apt doesn't get it?
User avatar
iconnor
Posts: 3356
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Options -> Web -> WEB_SOUND_ON_ALARM

Post by iconnor »

Should show up if you have the proposed ppa in your sources.list. What does apt-cache madison zoneminder say?
dougmccrary
Posts: 1373
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: Options -> Web -> WEB_SOUND_ON_ALARM

Post by dougmccrary »

Code: Select all

doug@doug-HP-Z400-ZM:~$ sudo apt-cache madison zoneminder
[sudo] password for doug: 
zoneminder | 1.36.33-focal1 | http://ppa.launchpad.net/iconnor/zoneminder-1.36/ubuntu focal/main amd64 Packages
zoneminder | 1.36.33~20230223.55-focal1 | http://ppa.launchpad.net/iconnor/zoneminder-proposed/ubuntu focal/main amd64 Packages
zoneminder | 1.32.3-2ubuntu2+esm1 | https://esm.ubuntu.com/apps/ubuntu focal-apps-security/main amd64 Packages
zoneminder | 1.32.3-2ubuntu2 | http://us.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
doug@doug-HP-Z400-ZM:~$ 
Also

Code: Select all

doug@doug-HP-Z400-ZM:~$ sudo apt policy zoneminder
[sudo] password for doug: 
zoneminder:
  Installed: 1.36.33-focal1
  Candidate: 1.36.33-focal1
  Version table:
 *** 1.36.33-focal1 500
        500 http://ppa.launchpad.net/iconnor/zoneminder-1.36/ubuntu focal/main amd64 Packages
        100 /var/lib/dpkg/status
     1.36.33~20230223.55-focal1 500
        500 http://ppa.launchpad.net/iconnor/zoneminder-proposed/ubuntu focal/main amd64 Packages
     1.32.3-2ubuntu2+esm1 500
        500 https://esm.ubuntu.com/apps/ubuntu focal-apps-security/main amd64 Packages
     1.32.3-2ubuntu2 500
        500 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
doug@doug-HP-Z400-ZM:~$ 
User avatar
iconnor
Posts: 3356
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Options -> Web -> WEB_SOUND_ON_ALARM

Post by iconnor »

Right. There are build issues on focal. SOmething wrong with my fixes for ffmpeg5.
dougmccrary
Posts: 1373
Joined: Sat Aug 31, 2019 7:35 am
Location: San Diego

Re: Options -> Web -> WEB_SOUND_ON_ALARM

Post by dougmccrary »

OK, thanks.
dawansv
Posts: 3
Joined: Wed Jun 07, 2017 6:33 pm

Re: Options -> Web -> WEB_SOUND_ON_ALARM

Post by dawansv »

I had trouble getting this to work on 1.36.35 so figured I would share what I did. My ZM is running on Ubuntu but I was trying to get the alarm to sound on Windows 11 with Chrome or Edge.

After some testing, I found that I couldn't get it working with the current <embed> tag. However I was able to get it working by using the newer <audio> tag. One advantage of the <audio> tag is that is has play() and pause() functions we can be used in the javascript file instead of the autostart option used by the <embed> tag.

So in /usr/share/zoneminder/www/skins/classic/views/watch.php, I made the following change:
I replaced
<embed src="<?php echo $soundSrc ?>"
autostart="true"
loop="true"
hidden="true">
</embed>
with

Code: Select all

<audio id="alarmAudio" 
	  src="<?php echo $soundSrc ?>"
	  loop="true"
	  hidden="true">
</audio>
Then in /usr/share/zoneminder/www/js/MonitorStream.js I made the following changes:

I replaced
$j('#alarmSound').removeClass('hidden');
with

Code: Select all

$j('#alarmAudio')[0].play();
and
$j('#alarmSound').addClass('hidden');
with

Code: Select all

$j('#alarmAudio')[0].pause();
Last thing was to deselect WEB_USE_OBJECT_TAGS in Options - Web to avoid ending up with the old mediaplayer option. I think in fact this whole section of media player in both files should be removed as it was I think mostly for IE which I don't think needs to be supported anymore. Not sure.

Finally, because of browser policy both in Chrome and Edge (and other chromium browsers I assume), in order for the alarm to sound, after opening the watch window for a camera, you must at least click on the screen once because the audio tag will not play only if you didn't interact at least once with the screen. Just clicking anywhere is enough.

PS: If you want a custom sound file, you need to put it in the sounds subdirectory within the zoneminder www directory.
On ubuntu that's located at /usr/share/zoneminder/www/sounds
There is ALARM.WAV by default in there but you can also define another one and set it via WEB_ALARM_SOUND in the Options - Web screen.
User avatar
iconnor
Posts: 3356
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Options -> Web -> WEB_SOUND_ON_ALARM

Post by iconnor »

Thanks for that analysis and detailed info. I'll look into this in a little while. I think there were some udpates in 1.37 to this but I don't remember if I pack ported them or what.

THere is definitely a TON of stuff in ZM that is no longer relevant. But I don't have the time to do the cleanup I'd like to do. Every now and then I remove something but the years go by...
Post Reply