HTML 5 Video Code

With the new features of HTML5 being constantly shoved in our faces, I though I’d share a little snippet of code that adjusts the initial volume of a video on a HTML page- this particular example is used at for the video header on the main page. The video was too loud when the client computer volume was at 100% so, we decided it needed lowering, without re-encoding the video.


<video id=“welcomevid” width=“620” height=“250” controls=“controls” autoplay=“autoplay” onplay=“document.getElementById(‘welcomevid’).volume=0.2;” ></video>

Note the id=“welcomevid” which is required in order to set the volume paramter in the DOM with the getElementById command.

Volume control is 0-1 with 0.5 being 50% etc. hence the use of 0.2 in this example.