I need to find some event that fires,when i press mute button.On volumechange works only, when i change volume.
<audio id="volumeController" onvolumechange="changeVolume()"controls>
<source src="~/Sounds/beep.mp3" type="audio/mpeg"/>
</audio>
also i tried to use onclick and onchange events but instead of current volume,it sends always 1 instead of 0.
In HTML5 there isn't any mute event , when you click on mute and media gets muted it still counted as volumechange
event .But there is another way that you can discern whether it's a mute or regular volumechage ; you can use muted
property it gets set to true
when you mute false
otherwise
var audio = document.getElementById('audio');
audio.addEventListener('volumechange',function(e){
if(this.muted)
console.log('Audio muted');
}, false);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.