Skip to content

Instantly share code, notes, and snippets.

@juliendkim
Created November 11, 2019 08:16
Show Gist options
  • Save juliendkim/35301628280e1d78fa101f33a1d34a6e to your computer and use it in GitHub Desktop.
Save juliendkim/35301628280e1d78fa101f33a1d34a6e to your computer and use it in GitHub Desktop.
Play video files on localhost
<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