使用video.js遇到的坑。VIDEOJS: WARN: Player “player3“ is already initialised. Options will not be applied.

如果你第一次渲染没问题,但从这个页面跳到别的页面,再跳回来,bug出现了!

VIDEOJS: WARN: Player "player3" is already initialised. Options will not be applied.

我使用的办法是销毁video,再重新初始化

 <video id="my-video" class='video-js' controls preload='none' width='280' height='200' poster='' ><source id='video-source' src='' type="application/x-mpegURL"></video>
 var videoPlayer = $("#my-video").get(0);
 if (typeof (videoPlayer) != "undefined") {
    var myPlayer = videojs('my-video');
        myPlayer.dispose();
    }
   videojs.options.flash.swf = "js/video.min.js/video-js.swf"
      var id = "my-video";
            $("#my-wrap").html("<video id='" + id + "' class='video-js' controls preload='none' width='280' height='200' poster='' ><source id='video-source' src='http://IP地址:8088/hls/stream.m3u8' type='application/x-mpegURL'></video>");
            //设置资源路径
           
            videojs(id, {}, function () { //自动播放
                // Player (this) is initialized and ready.
                var myPlayer = videojs(id);
                videojs(id).ready(function () {
                    var myPlayer = this;
                    myPlayer.play();
                });
               
            });
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值