video.js 一个页面同时播放多个视频的实例代码
2019/6/26 23:20:35
本文主要是介绍video.js 一个页面同时播放多个视频的实例代码,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
具体代码如下所述:
$(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);
需要做个延时,避免加载失败
总结
以上所述是小编给大家介绍的video.js 一个页面同时播放多个视频的实例代码,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
这篇关于video.js 一个页面同时播放多个视频的实例代码的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-30[OIDC in Action] 2. 基于OIDC(OpenID Connect)的SSO(纯JS客户端)
- 2024-03-29terraform jsonencode
- 2024-03-13vuex-persist
- 2024-03-11icons for vue
- 2024-03-07breadcrumbs react js
- 2024-03-06react login page example
- 2024-03-06react router uselocation
- 2024-03-04postgres jsonb_set
- 2024-03-01react native uuid
- 2024-02-29vuejs sidebar