RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
JavaScript怎么实现控制视频

这篇“JavaScript怎么实现控制视频”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“JavaScript怎么实现控制视频”文章吧。

成都创新互联公司自2013年起,先为湟中等服务建站,湟中等地企业,进行企业商务咨询服务。为湟中企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

具体代码如下所示:




Documenttitle>
<style>
figcaption {
text-align: center;
line-height: 150px;
font-family: "Microsoft Yahei";
font-size: 24px;
}
.player {
width: 720px;
height: 360px;
margin: 10px auto;
border: 1px solid #000;
background-color: #000;
position: relative;
border-radius: 6px;
}
.player video {
width: 720px;
height: 360px;
}
.controls {
width: 700px;
height: 40px;
background-color: rgba(255,255,0,0.3);
position: absolute;
bottom: 10px;
left: 10px;
border-radius: 10px;
}
.switch {
position: absolute;
width: 22px;
height: 22px;
background-color: red;
left: 10px;
top: 9px;
border-radius: 50%;
}
.progress {
width: 432px;
height: 10px;
position: absolute;
background-color: rgba(255,255,255,0.4);
left: 40px;
top: 15px;
border-radius: 4px;
overflow: hidden;
}
.curr-progress {
width: 0%;
height: 100%;
background-color: #fff;
}
.time {
width: 120px;
height: 20px;
text-align: center;
line-height: 20px;
font-size: 12px;
color: #fff;
position: absolute;
left: 510px;
top: 10px;
}
.extend {
position: absolute;
width: 20px;
height: 20px;
background-color: red;
right: 10px;
top: 10px;
}
style>
head>
<body>
<figure>  
<figcaption>视频案例figcaption>
<div class="player">
<video src="11.mp4">video>
<div class="controls">
<a href="#" class="switch">a>
<div class="progress">
<div class="curr-progress">div>
div>
<div class="time">
<span class="curr-time">00:00:00span>/
<span class="total-time">00:00:00span>
div>
<a href="#" class="extend">a>
div>
div>
figure>
<script>
var video = document.querySelector('video');
var playBtn = document.querySelector('.switch');
var currProgress = document.querySelector('.curr-progress');
var currTime = document.querySelector('.curr-time');
var totalTime = document.querySelector('.total-time');
var extend = document.querySelector('.extend');
var tTime = 0;
playBtn.onclick = function() {
if(video.paused){  // 如果视频是暂停的
video.play();    //play()播放  load()重新加载  pause()暂停
}else{
video.pause();
}
}
//当视频能播放(已经通过网络加载完成)时
video.oncanplay = function() {
tTime = video.duration;  //获取视频总时长(单位秒)
var tTimeStr = getTimeStr(tTime);
totalTime.innerHTML = tTimeStr;
}
//当视频当前播放时间更新的时候
video.ontimeupdate = function() {
var cTime = video.currentTime;  //获取当前播放时间 
var cTimeStr = getTimeStr(cTime);
console.log(cTimeStr);
currTime.innerHTML = cTimeStr;
currProgress.style.width = cTime/tTime*100+"%";
}
extend.onclick = function() {
video.webkitRequestFullScreen();  //视频全屏
}
//将以秒为单位的时间变成“00:00:00”格式的字符串
function getTimeStr(time) {
var h = Math.floor(time/3600);
var m = Math.floor(time%3600/60);
var s = Math.floor(time%60);
h = h>=10?h:"0"+h;
m = m>=10?m:"0"+m;
s = s>=10?s:"0"+s;
return h+":"+m+":"+s;
}
script>
body>
html></pre><p>以上就是关于“JavaScript怎么实现控制视频”这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注创新互联行业资讯频道。</p>            
            
            <br>
当前名称:JavaScript怎么实现控制视频<br>
网址分享:<a href="http://aqpgk.com/article/gddseh.html">http://aqpgk.com/article/gddseh.html</a>
</div>
<div class="hot_new">
<div class="page_title clearfix">
<h3>其他资讯</h3>
</div>
<div class="news_list clearfix">
<ul>
<li>
<a href="/article/cdgdjos.html">在香港搭建服务器</a>
</li><li>
<a href="/article/cdgdjdo.html">怎样做一个自己的网站?</a>
</li><li>
<a href="/article/cdgdgpj.html">零基础小白到高手!Linux云计算学习路线详解!(linux云计算从入门到精通)</a>
</li><li>
<a href="/article/cdgdjji.html">配置dns服务器详细步骤?(如何添加dns解析)</a>
</li><li>
<a href="/article/cdgdjec.html">怎么看王者排名?(怎么看王者排名第几)</a>
</li></ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 底部信息 -->
<div class="footer wow fadeInUp">
<div class="rowFluid">
<div class="span12">
<div class="container">
<div class="footer_content">
<div class="span4 col-xm-12">
<div class="footer_list">
<div class="span6">
<div class="bottom_logo"><img src="/Public/Home/images/ewm.jpg" alt="微信服务号二维码" /></div>
</div>
<div class="span6 col-xm-12">
<div class="quick_navigation">
<div class="quick_navigation_title">快速导航</div>
<ul>
<li><a href="http://www.lbtcd.cn/" title="成都力比特" target="_blank">成都力比特</a></li><li><a href="http://www.ysfcd.com/" title="成都电信西信机房托管" target="_blank">成都电信西信机房托管</a></li><li><a href="http://www.hongyifilm.cn/" title="鸿艺文化传播" target="_blank">鸿艺文化传播</a></li><li><a href="https://www.cdcxhl.cn/" title="成都机柜租用" target="_blank">成都机柜租用</a></li><li><a href="http://www.jiuxuanet.com/" title="成都公司注册全流程" target="_blank">成都公司注册全流程</a></li><li><a href="http://www.ytofo.com/" title="孝感市网站推广" target="_blank">孝感市网站推广</a></li><li><a href="http://www.ayerh.com/" title="摄影器材公司" target="_blank">摄影器材公司</a></li></ul>
</div>
</div>
</div>
</div>
<div class="span4 col-xm-6 col-xs-12">
<div class="footer_list">
<div class="footer_link">
<div class="footer_link_title">友情链接</div>
<ul id="frientLinks">
<a href="https://www.cdcxhl.com/" title="网站制作" target="_blank">网站制作</a>
<a href="https://www.cdcxhl.com/" title="网站建设" target="_blank">网站建设</a>
<a href="https://www.cdxwcx.com/tuiguang/" title="成都网络推广" target="_blank">网络推广</a>
<a href="http://seo.cdkjz.cn/" title="成都网站推广" target="_blank">网站推广</a>
<a href="https://www.cdcxhl.com/xiaochengx.html" title="成都微信小程序开发" target="_blank">小程序开发</a>
<a href="https://www.cdcxhl.com/menu.html" title="创新互联网站栏目导航" target="_blank">网站导航</a>
</ul>
<div class="footer_link_title">网站建设</div>
<ul id="frientLinks">
<li><a href="/">宜宾勤盛利枫建站</a></li>
<li><a href="https://www.cdcxhl.com/menu.html" title="创新互联网站栏目导航" target="_blank">网站导航</a></li>
</ul>
</div>
</div>
</div>
<div class="span4 col-xm-6 col-xs-12">
<div class="footer_list">
<div class="footer_cotact">
<div class="footer_cotact_title">联系方式</div>
<ul>
<li><span class="footer_cotact_type">企业:</span><span class="footer_cotact_content">四川勤盛利枫机电有限公司   </span></li>
<li><span class="footer_cotact_type">地址:</span><span class="footer_cotact_content">成都市青羊区太升南路288号</span></li>
<li><span class="footer_cotact_type">电话:</span><span class="footer_cotact_content"><a href="tel:18980820575" class="call">18980820575</a></span></li>
<li><span class="footer_cotact_type">网址:</span><span class="footer_cotact_content"><a href="/" title="宜宾网站建设">www.aqpgk.com</a></span></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="copyright">
<p>公司名称:四川勤盛利枫机电有限公司   联系电话:18980820575</p>
<p><a href="http://beian.miit.gov.cn" target="_blank" rel="nofollow">网站备案号:蜀ICP备2025168279号-11</a></p>
<p>宜宾勤盛利枫建站 宜宾网站建设 宜宾网站设计 宜宾网站制作 <a href="http://www.cdxwcx.cn/" target="_blank">成都做网站</a></p>
</div>
</div>
</div>
</div>
</body>
</html>
<script>
$(".technical_support_box_z_info_box img").each(function(){
var src = $(this).attr("src");    //获取图片地址
var str=new RegExp("http");
var result=str.test(src);
if(result==false){
var url = "https://www.cdcxhl.com"+src;    //绝对路径
$(this).attr("src",url);
}
});
window.onload=function(){
document.oncontextmenu=function(){
return false;
}
}
</script>