有支持M3U8格式的HTML5播放器吗?

有支持M3U8格式的HTML5播放器吗?,第1张

有,而且也很多。\x0d\x0a1.在目前支持较好的仍然是使用FlashPlayer来播放m3u8格式的视频,这样能够很好的利用计算机的性能,使视频质量达到最优良的效果,但不是h5。\x0d\x0a2.H5支持的视频格式,默认使用的是video标签,但是video不支持m3u8格式,因此需要用到开源的js库来解码视频流。\x0d\x0a3.总结调研结果,推荐常用的有hls.js,video.js,都是开源免费。还有几个需要注册才能使用的,不罗列说明。\x0d\x0a4.原生的标签支持,目前无法实现,再浏览器的不断更新迭代基础上,未来是会支持的,不需要我们自己扩展。\x0d\x0a5.除了3中说的几个,还有很多浏览器插件支持的方式,比如vlc插件,就很好用。\x0d\x0a\x0d\x0a总结,推荐在github上搜索hls.js,会发现很多可用的内容。

JW Player在HTML5模式下播放M3U8文件方法:

jwplayer("mediaplayer").setup({

playlist: [{

sources: [{

file: 'rtmp://' + path + '/' + name

},{

file: 'http://' + path + '/' + name // 这里可以写m3u8的url。

}]

}],

height: 360,

primary: "flash",

width: 640

})

有的,在浏览器上播放m3u8的视频地址有两种方式:

一、html的video标签的方式,这种方式播放很简单:

<!DOCTYPE hmtl>

<html>

<head>

<title>the5fire m3u8 test</title>

</head>

<body>

<video controls autoplay >

<source src="../v1d30/posts/2014/barcelona/barcelona.m3u8">

</video>

</body>

</html>

二、通过开源的swfobject.js以及两个flash组件:OSMF和HLSProvider来播放,代码如下:

<!DOCTYPE html>

<html>

<head>

<title>the5fire m3u8 test</title>

<script src="../staticfile/swfobject.js"></script>

</head>

<body>

<div id="player">

</div>

<script>

var flashvars = {

// M3U8 url, or any other url which compatible with SMP player (flv, mp4, f4m)

// escaped it for urls with ampersands

src: escape("http://www.the5fire.com/static/demos/diaosi.m3u8"),

// url to OSMF HLS Plugin

plugin_m3u8: "http://www.the5fire.com/static/demos/swf/HLSProviderOSMF.swf",

}

var params = {

// self-explained parameters

allowFullScreen: true,

allowScriptAccess: "always",

bgcolor: "#000000"

}

var attrs = {

name: "player"

}

swfobject.embedSWF(

// url to SMP player

"http://www.the5fire.com/static/demos/swf/StrobeMediaPlayback.swf",

// div id where player will be place

"player",

// width, height

"800", "485",

// minimum flash player version required

"10.2",

// other parameters

null, flashvars, params, attrs

)

</script>

</body>

</html>

通过嵌入以上代码就可以播m3u8了。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/6256757.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-19
下一篇 2023-03-19

发表评论

登录后才能评论

评论列表(0条)

保存