Skip to content

Instantly share code, notes, and snippets.

@james-mux
Created August 19, 2021 16:10
Show Gist options
  • Save james-mux/9e0249f15b9435b907fcb8a5f9e1959d to your computer and use it in GitHub Desktop.
Save james-mux/9e0249f15b9435b907fcb8a5f9e1959d to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html>
<head>
<title>Player Page</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
</head>
<body style="text-align: center;">
<script>
</script>
<video id="myVideo" controls width="640px" muted autoplay></video>
<script>
var vid = document.querySelector('#myVideo');
var hls;
if (typeof mux !== 'undefined') {
if (Hls.isSupported()) {
hls = new Hls();
hls.loadSource('https://stream.mux.com/C9dZbRctzZsk7012BGomcKYXEpDYoZeQZ.m3u8');
hls.attachMedia(vid);
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = videoSrc;
}
hls.on(Hls.Events.FRAG_CHANGED, function (event, data) {
let utcSeconds = data.frag.programDateTime;
console.log(data.frag);
console.log('Current DateTime ' + new Date(utcSeconds));
});
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment