Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 使用视频标签播放m3u8视频_Html_Http_Streaming_Video Streaming_Http Live Streaming - Fatal编程技术网

Html 使用视频标签播放m3u8视频

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&

此代码适用于我的android设备上的所有浏览器,但不适用于我计算机上的Firefox/Chrome/Safari。
我需要在所有设备上播放视频。我能做什么?

大多数浏览器本机不支持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>