Skip to content

Instantly share code, notes, and snippets.

@max-verem
Created May 12, 2017 09:39
Show Gist options
  • Save max-verem/09c2e9f0ef6bf28e3ca620dd639a8136 to your computer and use it in GitHub Desktop.
Save max-verem/09c2e9f0ef6bf28e3ca620dd639a8136 to your computer and use it in GitHub Desktop.
HLS playback sample
<html>
<head>
<style>
body {
width: 982px;
margin: 50px auto;
}
</style>
<!--
https://github.com/dailymotion/hls.js/
https://github.com/video-dev/hls.js
http://hlsbook.net/wp-content/examples/hls.min.js
-->
<script src="hls.min.js"></script>
<script type="text/javascript">
var interval = setInterval(function()
{
if(document.readyState === 'complete')
{
clearInterval(interval);
if(Hls.isSupported())
{
var m3u8 = "/hls2/stream.m3u8";
var video = document.getElementById('my-video');
var hls = new Hls();
hls.loadSource(m3u8);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function()
{
video.play();
});
}
}
}, 100);
</script>
</head>
<body>
<video id="my-video" width="854" height="480" controls></video>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment