简体   繁体   中英

Volume for HTML5 video tag

I tried to modify the volume of the video element with element.volume = whatever , where whatever is a value between 0 and 1. Unfortunately it doesn't work and I get no error in the console. I tried in both Firefox and Chrome.

I looked at https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_HTML5_audio_and_video and this should be the way.

I also looked at HTML5 Video Tag Volume Support and tried the method in the accepted answer to see if the browser supports it. Using that method (second one) it seems to be supported.

Am I missing something? Is there a well known bug for this?

How did you get your "element"? Maybe you should get the video element again before you assign the volume to see if works. I have been using html5 video player in the past 2 years and I didn't have any issue.

element = document.getElementById("VIDEO_ID");
element.volume = whatever;

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM