Html 我如何将此 m3u8 嵌入到我的网页中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29271658/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do i embed this m3u8 into my webpage?
提问by user4335407
My title says it all. i have m3u8 file i need to embed
我的标题说明了一切。我有需要嵌入的 m3u8 文件
tried using this method(below) but it says "video format or mime type is not supported"
尝试使用此方法(如下),但显示“不支持视频格式或 MIME 类型”
<div id='player'>
<video width=100% height=100% src="http://cdncities.com/deranalive/deranalive/playlist.m3u8" type="application/x-shockwave-flash" controls autoplay>
</video>
</div>
i tried jwplayer wizard, on there it works, but it not free.... i am dont know what to do.
我试过jwplayer 向导,在那里它可以工作,但它不是免费的......我不知道该怎么做。
anyone know a free player? or solution for that code?
有人知道免费播放器吗?或该代码的解决方案?
thanks.
谢谢。
回答by Mahmoud Elhassan Elhagagy
easy sir you can follow this file:
简单先生,您可以遵循此文件:
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<video id="video"></video>
<script>
if(Hls.isSupported()) {
var video = document.getElementById('video');
var hls = new Hls();
hls.loadSource('http://cdncities.com/deranalive/deranalive/playlist.m3u8');
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
video.play();
});
}
// hls.js is not supported on platforms that do not have Media Source Extensions (MSE) enabled.
// When the browser has built-in HLS support (check using `canPlayType`), we can provide an HLS manifest (i.e. .m3u8 URL) directly to the video element throught the `src` property.
// This is using the built-in support of the plain video element, without using hls.js.
else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = 'http://cdncities.com/deranalive/deranalive/playlist.m3u8';
video.addEventListener('canplay',function() {
video.play();
});
}
</script>
回答by aergistal
Only Safari 6.0+ has native HLS support. You can't use it with HTML5 on a desktop.
只有 Safari 6.0+ 具有本机 HLS 支持。您不能在桌面上将它与 HTML5 一起使用。
A free player that supports HLS via Flash is mediaelement.js
通过 Flash 支持 HLS 的免费播放器是mediaelement.js