html5视频播放器_手机端网页mp4播放器代码下载
程序员文章站
2022-03-01 12:39:32
...
分享一个JavaScript脚本、主要是实现了HTML5手机网页视频播放器、其中代码是一款基于jQuery HTML5实现的MP4网页视频播放器代码、效果非常珧、可以直接兼容手机浏览器和的、下面是效果图
HTML代码
<div class="playContent"> <div class="turnoff"> <ul> <li><a href="javascript:;" title="喜欢" class="glyphicon glyphicon-heart-empty"></a></li> <li><a href="javascript:;" title="关灯" class="btnLight on glyphicon glyphicon-sunglasses"></a></li> <li><a href="javascript:;" title="分享" class="glyphicon glyphicon-share"></a></li> </ul> </div> <video width="100%" height="100%" id="playVideo"> <source src="视频地址url" type="video/mp4"></source> 当前浏览器不支持 video直接播放,点击这里下载视频: <a href="/">下载视频</a> </video> <div class="playTip glyphicon glyphicon-play"></div> </div> <div class="playControll"> <div class="playPause playIcon"></div> <div class="timebar"> <span class="currentTime">0:00:00</span> <div class="progress"> <div class="progress-bar progress-bar-danger progress-bar-striped" role="progressbar" aria-valuemin="0" aria-valuemax="100" style="width: 0%"></div> </div> <span class="duration">0:00:00</span> </div> <div class="otherControl"> <span class="volume glyphicon glyphicon-volume-down"></span> <span class="fullScreen glyphicon glyphicon-fullscreen"></span> <div class="volumeBar"> <div class="volumewrap"> <div class="progress"> <div class="progress-bar progress-bar-danger" role="progressbar" aria-valuemin="0" aria-valuemax="100" style="width: 8px;height: 40%;"></div> </div> </div> </div> </div> </div>
JS代码的话相对来说比较多一点、但都已经封装好了、其中实现的功能包括播放和暂停、进度条、全屏、音量控制、关灯等功能、下面贴上部分代码
音量控制JS代码
function volumeControl(e) { e = e || window.event; var eventype = e.type; var delta = (e.originalEvent.wheelDelta && (e.originalEvent.wheelDelta > 0 ? 1 : -1)) || (e.originalEvent.detail && (e.originalEvent.detail > 0 ? -1 : 1)); var positions = 0; var percentage = 0; if (eventype == "click") { positions = volumebar.offset().top - e.pageY; percentage = 100 * (positions volumebar.height()) / $(´.volumeBar .volumewrap´).height(); } else if (eventype == "mousewheel" || eventype == "DOMMouseScroll") { percentage = 100 * (volumebar.height() delta) / $(´.volumeBar .volumewrap´).height(); } if (percentage < 0) { percentage = 0; $(´.otherControl .volume´).attr(´class´, ´volume glyphicon glyphicon-volume-off´); } if (percentage > 50) { $(´.otherControl .volume´).attr(´class´, ´volume glyphicon glyphicon-volume-up´); } if (percentage > 0 && percentage <= 50) { $(´.otherControl .volume´).attr(´class´, ´volume glyphicon glyphicon-volume-down´); } if (percentage >= 100) { percentage = 100; } $(´.volumewrap .progress-bar´).css(´height´, percentage ´%´); playVideo[0].volume = percentage / 100; e.stopPropagation(); e.preventDefault(); }
源代码下载链接: http://dwtedx.com/download.html?bdkey=s/1gdK7KFD 密码: xwxg