Created
November 11, 2019 08:16
-
-
Save juliendkim/35301628280e1d78fa101f33a1d34a6e to your computer and use it in GitHub Desktop.
Play video files on localhost
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
<input type="file" accept="video/*" /> | |
<video controls autoplay></video> | |
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> | |
<script> | |
$('input').on('change', changeEvent => { | |
var reader = new FileReader(); | |
reader.onload = onLoadEvent => $('video').attr('src', onLoadEvent.target.result).play(); | |
reader.readAsDataURL(changeEvent.currentTarget.files[0]); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment