I am trying to save the volume of a playing music file in a cookie so when the page is reloaded, the volume the user chose last is maintained, rather than turning up super loud or whatever.
Here's my test code for the eventlistener:
var myAudio = document.getElementById("audio1");
myAudio.addEventListener('change',alert("Audio Volume Changed"),true};
However, it does not respond when I change the volume. I've searched and despite it being something I think is pretty practical, there's no information on it.
You're looking for the "volumechange" event.
var audio = document.getElementById('sample');
audio.addEventListener('volumechange', function() {
console.log('changed.', arguments);
}, false);
I'm using the bubble phase(as opposed to capture) in this example.
http://www.w3.org/html/wg/drafts/html/master/embedded-content-0.html#event-definitions
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.