본문 바로가기

HLS M3U8 Player

반응형

반응형으로 사이즈가 조절되는 HLS Player 입니다.

소스

<!DOCTYPE html>
<html lang="ko" >
<head>
<meta charset="UTF-8">
<title>HLS Player</title>
<style>
.myvideo{
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
}
#video{
  position: absolute;
  width: 100%;
  height: 100%;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
</head>
<body>
<div class="myvideo">
<video autoplay playsinline controls id="video" controls></video>
</div>
 <script>
 var video = document.getElementById('video');
 var source = "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8";
 var hls = new Hls({
 debug: true,
 });
 hls.loadSource(source);
 hls.attachMedia(video);
 hls.on(Hls.Events.MEDIA_ATTACHED, function () {
 video.muted = true;
 video.play();
 });
</script>
</body>
</html>
반응형

댓글


Copyright ⓒ SmartWeb All rights reserved.