Skip to content

Instantly share code, notes, and snippets.

@philsinatra
Created January 16, 2017 16:39
Show Gist options
  • Save philsinatra/5c9bf992de8db856734e6f3a34af02bd to your computer and use it in GitHub Desktop.
Save philsinatra/5c9bf992de8db856734e6f3a34af02bd to your computer and use it in GitHub Desktop.
Javascript Volume Control
<video src="https://cdn.brad.is/videos/curiosity.mp4" id="video" width="640" height="360" controls> </video>
<script type="text/javascript">
var video = document.getElementById('video');
video.addEventListener("volumechange", function() {
console.log('Volume changed.');
console.log('Current volume: ' + video.volume);
var set_volume = localStorage.setItem('wo14_vol', video.volume);
});
var t = window.setTimeout(function() {
var get_volume = localStorage.getItem('wo14_vol');
if (get_volume) video.volume = get_volume;
video.play();
}, 1000);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment