Skip to content

Instantly share code, notes, and snippets.

@SalvadorP
Last active July 1, 2024 18:17
Show Gist options
  • Save SalvadorP/8ad13514004209165706 to your computer and use it in GitHub Desktop.
Save SalvadorP/8ad13514004209165706 to your computer and use it in GitHub Desktop.
Simple HTML 5 video player on demand, just paste the video URL and it will begin to play
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Simple HTML5 Video Player</title>
</head>
<body>
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<div>
Video URL: <input type="text" id="videoUrl" name="videoUrl">
</div>
<br />
<div>
<video width="640" height="480" id="video" controls>
<source src="" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
<script type="text/javascript">
$( document ).ready(function() {
$('#videoUrl').on('change', function(e) {
var video = $('#video');
video.children('source').attr('src', $(this).val());
video[0].load();
video[0].play();
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment