Created
June 7, 2018 22:23
-
-
Save stmoerman/c7ba7cf9e6ff5b5d8b1d49c4a1d13be2 to your computer and use it in GitHub Desktop.
This file contains 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 id="myvideo" controls muted loop> | |
<source src="sample_video_no_sound.mp4" type="video/mp4"/> | |
<audio id="myaudio"> | |
<source src="sound.mp3" type="audio/mpeg"/> | |
</audio> | |
</video> | |
<script> | |
var myvideo = document.getElementById("myvideo"); | |
var myaudio = document.getElementById("myaudio"); | |
var change_time_state = true; | |
myvideo.onplay = function(){ | |
myaudio.play(); | |
if(change_time_state){ | |
myaudio.currentTime = myvideo.currentTime; | |
change_time_state = false; | |
} | |
} | |
myvideo.onpause = function(){ | |
myaudio.pause(); | |
change_time_state = true; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment