Skip to content

Instantly share code, notes, and snippets.

@mayli
Created January 6, 2022 23:04
Show Gist options
  • Save mayli/6139696d16e780eb1008c50b81ecad1a to your computer and use it in GitHub Desktop.
Save mayli/6139696d16e780eb1008c50b81ecad1a to your computer and use it in GitHub Desktop.
bGojpxg
<div id="v"></div>
// var video = document.getElementById("video");
for(i=1;i < 18;i ++){
const video = document.createElement("video");
video.setAttribute("height", 120); video.setAttribute("control", 1);
const currentDiv = document.getElementById("v");
document.body.insertBefore(video, currentDiv);
if (Hls.isSupported()) {
var hls = new Hls({
debug: true
});
hls.loadSource("https://iptv.jmsooo.com/live/cctv"+i+"/index.m3u8");
hls.attachMedia(video);
hls.on(Hls.Events.MEDIA_ATTACHED, function () {
video.muted = true;
video.play();
});
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/hls.js/1.1.2/hls.min.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment