Html 使用视频标签播放m3u8视频
此代码适用于我的android设备上的所有浏览器,但不适用于我计算机上的Firefox/Chrome/Safari。Html 使用视频标签播放m3u8视频,html,http,streaming,video-streaming,http-live-streaming,Html,Http,Streaming,Video Streaming,Http Live Streaming,此代码适用于我的android设备上的所有浏览器,但不适用于我计算机上的Firefox/Chrome/Safari。 我需要在所有设备上播放视频。我能做什么?大多数浏览器本机不支持HLS。但是可以通过诸如hls.js之类的库进行播放。这应该很容易实现 <video width="352" height="198" controls> <source src="video.m3u8" type="application/x-mpegURL"> </video&
我需要在所有设备上播放视频。我能做什么?大多数浏览器本机不支持HLS。但是可以通过诸如hls.js之类的库进行播放。这应该很容易实现
<video width="352" height="198" controls>
<source src="video.m3u8" type="application/x-mpegURL">
</video>
如果(Hls.isSupported()){
var video=document.getElementById('video');
var hls=新的hls();
hls.loadSource('https://video-dev.github.io/streams/x36xhzz/x36xhzz.m3u8');
附件媒体(视频);
on(hls.Events.MANIFEST_已解析,函数(){
video.play();
});
}
感谢您的帮助,它与hls.js完美配合!
<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('https://video-dev.github.io/streams/x36xhzz/x36xhzz.m3u8');
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED,function() {
video.play();
});
}
</script>