Skip to content

Instantly share code, notes, and snippets.

@IKHMedia
Created August 28, 2023 15:16
Show Gist options
  • Save IKHMedia/f1f2aec76dac7430ad3bfa864e34069f to your computer and use it in GitHub Desktop.
Save IKHMedia/f1f2aec76dac7430ad3bfa864e34069f to your computer and use it in GitHub Desktop.
m3u8-video-js
<link href="https://cdnjs.cloudflare.com/ajax/libs/video.js/5.10.2/alt/video-js-cdn.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/video.js/5.10.2/video.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-hls/3.0.2/videojs-contrib-hls.js"></script>
<input type="text" id="url" style="width:100%" value="https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8"> <input type="button" id="btn" value="play">
<br><br>
<video id="video" class="video-js vjs-default-skin" preload="none" crossorigin="true" controls width="640" height="268" controls>
</video>
$(document).ready(function() {
$("#btn").on("click", function() {
$("#video").html("<source src='"+ $("#url").val() +"' type='application/x-mpegURL'>");
var ply = videojs("video");
ply.play();
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment