js前端网页播放m3u8或则flv直播流

时间:2024-02-24 07:36:20
<div id="playercontainer"></div>
<script type="text/javascript" src="../video/cyberplayer.js"></script>
<script type="text/javascript">
    var player = cyberplayer("playercontainer").setup({
        image:"../video/banner0.png",//相当于video标签的poster图片
        width: 1280,
        height: 720,
        stretching: "uniform",
//        file: "http://play.bcelive.com/live/lss-hbzkvrv1bucqcb0y.flv",
        file: "http://hbruagstgnqx15jf9xv.exp.bcelive.com/lss-hbzkvrv1bucqcb0y/live.m3u8",//需要播放的流地址。
        autostart: false,
        repeat: false,
        volume: 100,
        controls: true,
        isLive: true,
        type: "m3u8",
        rtmp: {
            reconnecttime: 10,
            bufferlength: 1
        },
        ak: "xxxxxxxxxxxxxxxx" // 公有云平台注册即可获得accessKey
    });
</script>

注意:引用cyberplayer.js时,同文件下记得要有cyberplayer.flash.swf文件,这两个文件官网都可以下载到。放在同文件下会自行找到cyberplayer.flash.swf,无需再次引用。

另:cyberplayer.js和cyberplayer.flash.swf,要放在服务器端哦,不然会提示加载视频错误,开一个(node)本地服务器就好了。