Created
January 16, 2017 16:39
-
-
Save philsinatra/5c9bf992de8db856734e6f3a34af02bd to your computer and use it in GitHub Desktop.
Javascript Volume Control
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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