I have a rather complicated project at work that requires a custom volume slider to control an HTML5 video element. I pushed the volume control down to a very simple example, and I see no reason why it should not work. I would like to know about the following code:
JQuery
<script> $(function() { $('#volume').change(function () { newvolume = $('#volume').attr("value") / 100; $('#video').attr("volume", newvolume); console.log($('#video').attr("volume")); }); }); </script>
HTML:
<video id="video" controls="controls"> <source src="http://dev.domain.com/media/16514.m4v"> </video> <input id="volume" type="range" min="0" max="100" value="100" />
It should be noted that every aspect of this seems to work, except for an audible change in the volume of the video clip. Even the result of console.log returns the correct value (from 0 to 1.00). I also tried a strictly Javascript version of this, i.e. videoElement.volume = newvolume
If this is important, I am testing Safari 5.1.2.
jquery html5-video
MetaSkills Jan 12 '12 at 11:17 2012-01-12 11:17
source share