如果你第一次渲染没问题,但从这个页面跳到别的页面,再跳回来,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();
                });
               
            });
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐