当前位置: 移动技术网 > IT编程>开发语言>JavaScript > video.js 一个页面同时播放多个视频

video.js 一个页面同时播放多个视频

2018年11月27日  | 移动技术网IT编程  | 我要评论
$(data).each(function(i, item) {
            // innerhtml += '<li type-id="'+item.id+'">'+
            //              '<img src="'+(item.imgs?item.imgs:'../../img/videobg1.jpg')+'" alt="">'+
            //              '<p>'+item.name+'</p>'+
            //              '</li>';
            innerhtml += '<li type-id="' + item.id + '">' +
                // '<img src="'+(item.imgs?item.imgs:'../../img/videobg1.jpg')+'" alt="">'+
                '<video style="width:100%;height:100%;" id="example_video_' + item.id + '" class="videoclass video-js vjs-default-skin vjs-big-play-centered" autoplay="autoplay" controls muted><source src="' + item.hls + '" type="application/x-mpegurl">' +
                '</video>' +
                '<p>' + item.name + '</p>' +
                '</li>';
            //视频实时播放
            settimeout(function() {
                var myplayer = videojs('example_video_' + item.id);
                videojs('example_video_' + item.id).ready(function() {
                    var myplayer = this;
                    myplayer.play();
                });
            }, 5000);
        });

引入video.css 和video.js 为前提

调用主要是

settimeout(function() {
                var myplayer = videojs('example_video_' + item.id);
                videojs('example_video_' + item.id).ready(function() {
                    var myplayer = this;
                    myplayer.play();
                });
            }, 5000);
需要做个延时,避免加载失败

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网