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

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐