專案有個需求 , 由前端取得m3u8的內容後做播出
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="referrer" content="no-referrer">
<title>Document</title>
</head>
<body>
<video id="video" controls></video>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script>
var manifest = 'm3u8的內容';
var video = document.getElementById('video');
var blob = new Blob([manifest]);
var hls = new Hls();
var url = URL.createObjectURL(blob);
hls.loadSource(url);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function() {
video.play();
});
</script>
</body>
</html>