一个有趣的html5播放器
2016-03-29 17:25
459 查看
复制直接可以看片,反正我信了!
提示: 先去下载一个mv,改变vodeo一下中src中的路径,就可以了。
提示: 先去下载一个mv,改变vodeo一下中src中的路径,就可以了。
<span style="font-size:14px;"><strong><!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>html5 视频</title> </head> <style type="text/css"> li{list-style:none;color:#fff;} a:hover{color:#f00;} li:hover{color:#f00;cursor: pointer;} </style> <body > <div style="background-color:#fff;width:1000px;height:600px;"> <div style="margin-left:20%;"> <header> <div> 当前播放 :<a > <!-- id="currentMovie" -->《画江湖之灵主》</a><br> 当前播放速度 : <span id="currentSpeed">1X</span><br> 当前声音大小为 :<span id="currentVolume">100</span><br> </div> </header> <section> <article> <video style="float:left;" id="testVideo" preload="metadata" src="/jiami/images/1.mp4" height="300" controls> 你的浏览器不支持html5视频 </video> <div style="float:left;background-color:rgb(48,48,48);width:200px;height:317px;overflow:scroll;"> <h4 style="color:rgb(166,166,166);font-weight:bold;width:200px;float:left;"><span>播放列表</span> <span >集数列表</span></h4> <hr> <ul style=""> <li>喜洋洋灰太狼</li> <li>蜡笔小新</li> <li>龙珠</li> <li>喜洋洋灰太狼</li> <li>蜡笔小新</li> </ul> </div> </article> <article style="clear:both;"> <br/> <button class="btn btn-primary" id="play">播放</button> <button class="btn btn-primary" id="pause">暂停</button> <button class="btn btn-primary" id="stop">停止</button> <button class="btn btn-primary" id="prev">下集</button> <button class="btn btn-primary" id="next">上集</button> <button class="btn btn-primary" id="upVolume">音量+</button> <button class="btn btn-primary" id="downVolume">音量-</button> <button class="btn btn-primary" id="fastFoward">快进</button> <button class="btn btn-primary" id="fastBackward">快退</button> <br/> <!-- 从<input type="text" id="min" style="width:20px;" value="0"/>分跳转到<input type="text" id="sec" style="width:20px;" value="0"/>播放 <button id="locate">确认</button> --> </article> <section> </div> </div> <script type="text/javascript"> var $ = function(id){return document.getElementById(id);}; var _video = $("testVideo"); //视频列表 var playList = { current : 0, list : ["画江湖之灵主.ogg","war3.ogg","movie.ogv","trailer.webm","trailer.ogv"] } var videoUtil = { //播放 play : function(){ _video.play(); }, //暂停 pause : function(){ _video.pause(); }, //停止 stop : function(){ _video.currentTime = 0; _video.pause(); }, //下一个视频 next : function(){ if(playList.current == playList.list.length-1){ playList.current = 0; }else{ playList.current++; } _video.src=playList.list[playList.current]; _video.play(); }, //前一个视频 prev : function(){ if(playList.current == 0){ playList.current = palyList.list.length-1; }else{ playList.current--; } _video.src=playList.list[playList.current]; _video.play(); }, //加大声音,每次加大1/10 upVolume : function(){ _video.volume += 0.1; }, //减小声音,每次减小1/10 downVolume : function(){ _video.volume -= 0.1; }, //翻倍加快播放速度 fastFoward : function(){ //FF不支持playbackRate if(_video.playbackRate){ _video.playbackRate = _video.playbackRate*2; }else{ alert("对不起,你的浏览器不支持改变播放速度!"); } }, //降低播放速度 fastBackward : function(){ if(_video.playbackRate){ _video.playbackRate = _video.playbackRate/2; }else{ alert("对不起,你的浏览器不支持改变播放速度!"); } }, //跳转到指定时间点播放 locate : function(){ var min = $("min").value; var sec = $("sec").value; var time = parseInt(min)*60+parseInt(sec); _video.currentTime = time; _video.play(); }, bindEvent : function(){ var self = this; //绑定页面上各个按钮的事件 var btns = document.getElementsByTagName("button"); for(var i = 0 ;i < btns.length ; i++){ var el = btns[i]; el.onclick = self[el.id]; } //播放完毕自动播放下一个 _video.onended = function(){ var event = document.createEvent("HTMLEvents"); event.initEvent('click', true, true); $("next").dispatchEvent(event); } //循环检查视频的当前状态 setInterval(function(){ var speed = _video.playbackRate||1; var movie = "movie"+playList.current; var volume = parseInt(_video.volume*100); $("currentMovie").innerHTML = movie; $("currentSpeed").innerHTML = speed+"X"; $("currentVolume").innerHTML = volume; },200); } }; window.onload = function(){ videoUtil.bindEvent(); } </script> </body> </html></strong></span>
相关文章推荐
- Html5之高级-6 HTML5 Canvas绘图(Canvas概述、Canvas绘图、处理 Canvas 中的图像)
- 一个有趣的html5手机锁
- 多种方法实现H5网页图片动画效果;
- HTML5表单属性(四)
- Html5之高级-5 HTML5音频处理(在H5中播放音频、编程实现音频播放器)
- html5 svg
- Html5之高级-4 HTML5视频处理(H5中播放视频、编程实现视频播放器)
- Html5之高级-3 HTML5表单验证(验证属性、验证状态)
- html5重要元素
- html5重要元素
- Html5之高级-2 HTML5表单属性(属性介绍、属性详解)
- html5移动web开发实战必读书记
- Html5之高级-1 HTML5表单元素(表单简介、input类型、新表单元素)
- HTML5表单属性(三)
- HTML5实现图片压缩上传功能
- 节日来了发个HTML5红包
- 使用 HTML5 WebSocket 构建实时 Web 应用
- 第六次HTML5
- HTML5与CSS3基础(五)
- HTML5 WebSockets 总结