How to remove/decrease sound volume on embedded YouTube video (HTML5 player)?


#1

Hello, I have a question–may be somebody does know how to remove or better, significantly decrease the volume of YouTube video while it is embedded on website?

I mean, if I set video to autoplay (that what I need), naturally that sound starts playing automatically too. What I need however, is a video started playing automatically while sound should be almost inaudible. If an user will want, he/she will increase the volume manually. Is there some solution for such the task? I looked through this document but did not find anything related.

Thank you in advance!


#2

its done with a bit of javascript

for setting the sound at 10%

var video=document.getElementById("videoId");

video.volume=0.1;


#3

Using YouTube JavaScript Player API Reference, this would help :
https://developers.google.com/youtube/youtube_player_demo


#4
MoJs said

Using YouTube JavaScript Player API Reference, this would help :
https://developers.google.com/youtube/youtube_player_demo

Many thanks for your tip!

Regrettably, it has its downside: I tried similar trick before by just removing the volume on player and afterwards pasting the code of video x into html page. The problem is that it affects all YouTube videos–if one increases the volume on any other video (whether it is on some website or YouTube site itself) the volume increases automatically on that very video x. And vice versa–once it is lowered on video x, all videos play with a low sound. That is why this solution is not good for me. But anyway, thank you!


#5
fAntasticmE said

its done with a bit of javascript

for setting the sound at 10%

var video=document.getElementById("videoId");

video.volume=0.1;

Thank you very much! This did not work but you gave me the right direction–to think about js. I overlooked this part of YouTube API: https://developers.google.com/youtube/iframe_api_reference, having paid attention to this part only: https://developers.google.com/youtube/player_parameters

After reading iframe API document I made what I needed with this function:

html:

js:

.................
 function onPlayerReady(event) {
  event.target.setVolume(2);
  event.target.playVideo();
}

Many thanks, task is fulfilled for now.


#6

Heylooo,

Is this code still working ? Dont arrive to use it…

Thx