General > General Discussion
Disable notification sounds
njak:
--- Quote ---Zappa: Turning the sound off by default won't help as the browser still seems to get the embed instruction and still prompts the user for the plugin. I managed to diable sound completely on the clinet side but it involved removing the playsound function from the JS files and only loading it for agents. Wasn't easy to change and won't be something that non-developers can do easily so an admin setting to turn sound off completely for end users would be awesome.
--- End quote ---
Anyway you can post what you did or at least give us a clue what to look for?
Zappa:
I will dig through my code and post here what I can when I find it. It wasn't an easy thing to find or change and had to make some core file changes which I wouldn't recommend for the faint hearted :)
--- Quote from: njak on January 09, 2012, 08:10:11 PM ---
--- Quote ---Zappa: Turning the sound off by default won't help as the browser still seems to get the embed instruction and still prompts the user for the plugin. I managed to diable sound completely on the clinet side but it involved removing the playsound function from the JS files and only loading it for agents. Wasn't easy to change and won't be something that non-developers can do easily so an admin setting to turn sound off completely for end users would be awesome.
--- End quote ---
Anyway you can post what you did or at least give us a clue what to look for?
--- End quote ---
Zappa:
Okay I had a look at my code. What I did was get hold of the un-minified js files and removed the sound function from common.js:
--- Code: ---function playSound(wav_file) {
var player = document.createElement("div");
var agt = navigator.userAgent.toLowerCase();
if(agt.indexOf('opera') != -1) {
player.style = "position: absolute; left: 0px; top: -200px;";
}
document.body.appendChild(player);
player.innerHTML = '<embed src="'+wav_file+'" hidden="true" autostart="true" loop="false">';
}
--- End code ---
and placed it into a new js file called "sound.js" in the /js/164 folder. I then linked to this file from the chat.tpl file in my relevant /style folder with code instructions for only agents to load the file like this:
--- Code: ---${if:agent}
<script type="text/javascript" src="${webimroot}/js/${jsver}/sound.js"></script>
${endif:agent}
--- End code ---
Next was to stop the function from executing in case it gets called by client scripts somewhere along the line so in chats.js change this code:
--- Code: ---if(!this.skipNextsound) {
var tsound = $('soundimg');
if(tsound == null || tsound.className.match(new RegExp("\\bisound\\b")) ) {
playSound(Chat.webimRoot+'/sounds/new_message.wav');
}
}
--- End code ---
and replace it with this:
--- Code: ---if (typeof playSound=="function") {
if(!this.skipNextsound) {
var tsound = $('soundimg');
if(tsound == null || tsound.className.match(new RegExp("\\bisound\\b")) ) {
playSound(Chat.webimRoot+'/sounds/new_message.wav');
}
}
}
--- End code ---
What that means is that any only agents will get sound notifications for new messages and clients don't get the instruction to embed the Quicktime object in their browser. I actually edited the minified verions of these js files with the minified code versions of the above changes but I wouldn't recommend that to most people :)
Something else to keep in mind is that only the javascript files in the /js/164 folder are actually used during script execution. The /js/source folder only contains the unminified versions of the files in the /js/164 folder for reference so any changes have to be made to the files in the /js/164 folder to have any effect.
egifford:
Responding to such an old post may be bad form, but I wanted to add that I just made this change to 1.6.4 and it works great. Sound is disabled and the end user to our site is no longer asked to allow plugins to work.
Thanks, Zappa, for the code!
okpa:
not work
Navigation
[0] Message Index
[*] Previous page
Go to full version