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

[HTML5]视频播放列表的示例源代码

时间:2017-08-16 17:28CSDN
[HTML5]视频播放列表的示例源代码

[HTML5]视频播放列表的示例源代码

  1. <video  id="myvideo" width="100%" height="auto" controls="controls" >   
  2.             你的浏览器不支持HTML5播放此视频   
  3. <span style="white-space:pre">    </span><!-- 支持播放的文件格式 -->   
  4.     <source src="video/01.mp4" type='video/mp4' />    
  5. </video>   
  1. <script language="javascript">     
  2.                         $(document).ready(function(){   
  3.                              video.play();     
  4.                         });   
  5.                            
  6.                         var vList = ['video//01.mp4', 'video//1.mp4', 'video//02.mp4']; // 初始化播放列表     
  7.                         var vLen = vList.length;    
  8.                         var curr = 0;    
  9.                         var video = document.getElementById("myvideo");     
  10.                         video.addEventListener('ended', function(){   
  11.                             play();   
  12.                         });     
  13.                             
  14.                         function play() {     
  15.                             video.src = vList[curr];     
  16.                             video.load();      
  17.                             video.play();     
  18.                             curr++;     
  19.                             if(curr >= vLen){     
  20.                                 curr = 0; //重新循环播放   
  21.                             }     
  22.                              
  23.                         }     
  24.                         </script>     

来源:http://blog.csdn.net/clypm/article/details/50324801

热门文章推荐

请稍候...

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

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