·您当前的位置:首页 > 技术教程 > Html5技术 >

[html5]多视频列表连播效果(实现原理)代码参考

时间:2017-10-25 23:29酷播
[html5]多视频列表连播效果(实现原理)

[html5]多视频列表连播效果(实现原理)代码参考

  1. <div id="playervideo" class="portfolio-slideshow flexslider animate-onscroll">   
  2.        
  3.                         <!-- Video player -->   
  4.                         <!--poster is 缩略图-->   
  5.                            
  6.                         <video id="example_video_1" class="video-js vjs-default-skin" 
    controls 
    preload="none" poster="video/demo.jpg" data-setup="{}" height="500" width="100%">   
  7.                             <source src="video/demo.mp4" type='video/mp4' />   
  8.                         </video>   
  9.                         <script language="javascript">   
  10.                         var vList = ['video//demo.mp4', 'video//demo01.mp4', 'video//demo.mp4']; // 初始化播放列表   
  11.                         var vLen = vList.length; // 播放列表的长度   
  12.                         var curr = 0; // 当前播放的视频   
  13.                            
  14.                         var video = document.getElementById("example_video_1");   
  15.                            
  16.                         /*var video = document.createElement("VIDEO");  
  17.                         video.setAttribute("width", "100%");  
  18.                         video.setAttribute("height", "500");  
  19.                         video.setAttribute("id", "example_video_1");  
  20.                         video.setAttribute("class", "video-js vjs-default-skin");  
  21.                         video.setAttribute("preload", "none");  
  22.                         video.setAttribute("poster", "video//demo.jpg");  
  23.                         video.setAttribute("data-setup", "{}");  
  24.                         video.setAttribute("controls", "yes");  
  25.                         document.getElementById("playervideo").appendChild(video);*/   
  26.                         //document.body.appendChild(video);   
  27.    
  28.                         video.addEventListener('ended', play);   
  29.                         play();   
  30.                         function play(e) {   
  31.                             video.src = vList[curr];   
  32.                             video.load();    
  33.                             video.play();   
  34.                             curr++;   
  35.                             if(curr >= vLen){   
  36.                                 curr = 0; // 播放完了,重新播放   
  37.                             }   
  38.                            
  39.                         }   
  40.                         </script>   
  41.                         <!-- /Video player -->   
  42.                             </div>   

 

热门文章推荐

请稍候...

保利威视云平台-轻松实现点播直播视频应用

酷播云数据统计分析跨平台播放器