.m3u8用html代码怎么写

html-css010

.m3u8用html代码怎么写,第1张

有的,在浏览器上播放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了。

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