JavaScript如何实现控制视频-创新互联-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

JavaScript如何实现控制视频-创新互联

这篇文章将为大家详细讲解有关JavaScript如何实现控制视频,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

站在用户的角度思考问题,与客户深入沟通,找到吴中网站设计与吴中网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都做网站、网站建设、企业官网、英文网站、手机端网站、网站推广、域名申请、网络空间、企业邮箱。业务覆盖吴中地区。

具体代码如下所示:




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://kswsj.cn/article/gpeid.html">http://kswsj.cn/article/gpeid.html</a>
        </div>
    </div>
    <div class="other">
        <h3>其他资讯</h3>
        <ul>
            <li>
                    <a href="/article/ijpcoc.html">FreeBSD通过虚拟光驱加载iso文件的方法</a>
                </li><li>
                    <a href="/article/ijpdjd.html">python注释符有什么用</a>
                </li><li>
                    <a href="/article/ijpdgi.html">PXE服务环境的部署和测试</a>
                </li><li>
                    <a href="/article/ijpdce.html">如何解决java压缩文件乱码问题</a>
                </li><li>
                    <a href="/article/ijpdhe.html">java编写的界面如何调用python</a>
                </li>        </ul>
    </div>
</div>
<div class="line"></div>
<!--底部-->
<footer id="5">
    <div class="foot1 container">
        <div class="list">
            <div class="item">
                <a href="javascript:;">
                    <span class="ico1"><i class="iconfont"></i><img src="/Public/Home/img/ewm.png" alt=""></span>
                    <strong>关注我们</strong>
                </a>
            </div>
            <div class="item">
                <a href="" target="_blank">
                    <span><i class="iconfont"></i></span>
                    <strong>索要报价</strong>
                </a>
            </div>
            <div class="item">
                <a href="" target="_blank">
                    <span><i class="iconfont"></i></span>
                    <strong>我要咨询</strong>
                </a>
            </div>
            <div class="item">
                <a href="" target="_blank">
                    <span><i class="iconfont"></i></span>
                    <strong>找到我们</strong>
                </a>
            </div>
            <div class="item">
                <a href="" target="_blank">
                    <span><i class="iconfont"></i></span>
                    <strong>投诉建议</strong>
                </a>
            </div>
        </div>
        <div class="tel">
            <dl>
                <tel><a href="tel:400-028-6601" target="_blank">400-028-6601</a></tel><br>
                <span>也许您需要专业的服务,欢迎来电咨询</span>
            </dl>
            <dl>
                <tel><a href="tel:18980820575" target="_blank">18980820575</a></tel><br>
                <span>您的需求,是我们前进的动力</span>
            </dl>
        </div>
    </div>
    <div class="friend">
        <div class="container">
            <span class="tit">友情链接:</span>
            <div class="inner">
                <a href="https://www.cdcxhl.com/hangyead/" target="_blank">1元广告</a><a href="https://www.cdcxhl.com/shoulu/" target="_blank">网站收录</a><a href="https://www.cdcxhl.com/xiaochengx.html" target="_blank">微信小程序开发</a><a href="https://www.cdcxhl.com/tuoguan/dianxin/" target="_blank">绵阳服务器托管</a><a href="https://www.cdcxhl.com/mobile.html" target="_blank">成都手机网站建设</a><a href="https://www.cdcxhl.com/xiangyingshi.html" target="_blank">成都响应式网站建设</a><a href="https://www.cdcxhl.com/google.html" target="_blank">成都谷歌推广</a><a href="https://www.cdcxhl.com/yingxiao.html" target="_blank">营销网站建设</a><a href="https://www.cdcxhl.com/mobile.html" target="_blank">成都手机网站建设公司</a><a href="https://www.cdcxhl.com/wangzhandingzhi.html" target="_blank">成都定制网站</a><a href="https://www.cdcxhl.com/gaiban/" target="_blank">网站改版公司</a><a href="https://www.cdcxhl.com/link/" target="_blank">买链接</a><a href="https://www.cdcxhl.com/wangzhandingzhi.html" target="_blank">成都定制网站网页设计</a><a href="https://www.cdcxhl.com/gaiban/" target="_blank">成都网站改版公司</a><a href="https://www.cdcxhl.com/" target="_blank">成都建站</a><a href="https://www.cdcxhl.com/yunying.html" target="_blank">成都网站托管</a><a href="https://www.cdcxhl.com/waimao.html" target="_blank">外贸网站建设</a><a href="https://www.cdcxhl.com/xiaochengx.html" target="_blank">成都微信小程序开发</a>            </div>
        </div>
    </div>
    <div class="foot">
        <div class="container">
            <div class="footNav">
                <h3>网站建设</h3>
                <a href="http://m.cdcxhl.com/" target="_blank">网站建设推广</a><a href="https://www.cdxwcx.com/wangzhan/pinpai.html" target="_blank">品牌网站建设公司</a><a href="http://chengdu.cdcxhl.com/" target="_blank">成都网站建设</a>            </div>
            <div class="footNav">
                <h3>服务器托管</h3>
                <a href="https://www.cdcxhl.com/idc/cqyd.html" target="_blank">重庆移动机房托管</a><a href="https://www.cdxwcx.com/jifang/xiyun.html" target="_blank">成都西云机房</a><a href="https://www.cdcxhl.com/jigui/" target="_blank">服务器机柜租用</a>            </div>
            <div class="footNav">
                <h3>网站制作</h3>
                <a href="http://www.cdxwcx.cn/" target="_blank">成都网站制作</a><a href="http://www.scyanting.com/" target="_blank">盐亭网站制作公司</a><a href="http://chengdu.cdcxhl.com/" target="_blank">成都营销网站制作</a>            </div>
            <div class="footNav">
                <h3>企业服务</h3>
                <a href="https://www.cdcxhl.com/service/service.html" target="_blank">工商服务</a><a href="https://www.cdcxhl.com/shoulu/" target="_blank">网站收录</a><a href="https://www.cdcxhl.com/mianfei/jianshe/chengdu.html" target="_blank">免费网站建设</a>            </div>
            <div class="fr ecode">
                <div class="fl">
                    <img src="/Public/Home/img/ewm.jpg">
                    <p>关注企业微信</p>
                </div>
                <div class="fr slogan">
                    <p class="icon">
                        <a class="ph" href=""><i class="iconfont"></i></a>
                        <a class="qq" href="tencent://message/?uin=1683211881&Site=&Menu=yes"><i class="iconfont"></i></a>
                    </p>
                    <p>
                        <i>想要找 </i> <a href="">小程序开发</a>、<a href="">APP开发</a>、
                        <a href="">营销型网站建设</a>、<a href="">网站建设</a>、
                        <i><a href="">网站定制开发</a></i> ,就选<a href="">创新互联</a>
                    </p>
                </div>
            </div>
        </div>
        <div class="bottom container">
            <p class="fl">
                版权所有:成都创新互联科技有限公司
                备案号:<a href="https://beian.miit.gov.cn/" target="_blank" rel="nofollow">蜀ICP备19037934号</a>
                服务热线:028-86922220
            </p>
            <p class="fr">
                <a href="https://www.cdxwcx.com/" target="_blank">成都网站建设</a>:
                <a href="https://www.cdcxhl.com/" target="_blank">创新互联</a>
            </p>
        </div>
    </div>
</footer>
<!--在线咨询-->
<div class="fot">
    <ul>
        <li>
            <a href="https://p.qiao.baidu.com/cps/mobileChat?siteId=11284691&userId=6256368&type=1&reqParam=%20{%22from%22:0,%22sessionid%22:%22%22,%22siteId%22:%2211284691%22,%22tid%22:%22-1%22,%22userId%22:%226256368%22,%22ttype%22:1,%22siteConfig%22:%20{%22eid%22:%226256368%22,%22queuing%22:%22%22,%22siteToken%22:%226ce441ff9e2d6bedbdfc2a4138de449e%22,%22userId%22:%226256368%22,%22isGray%22:%22false%22,%22wsUrl%22:%22wss://p.qiao.baidu.com/cps3/websocket%22,%22likeVersion%22:%22generic%22,%22siteId%22:%2211284691%22,%22online%22:%22true%22,%22webRoot%22:%22//p.qiao.baidu.com/cps3/%22,%22bid%22:%22160142915792139572%22,%22isSmallFlow%22:0,%22isPreonline%22:0,%22invited%22:0%20},%22config%22:%20{%22themeColor%22:%224d74fa%22%20}%20}&appId=&referer=&iswechat=0&expectWaiter=-1&openid=null&otherParam=null&telephone=null&speedLogId=null&eid=null&siteToken=6ce441ff9e2d6bedbdfc2a4138de449e" target="_blank">
                <img src="/Public/Home/img/fot1.png" alt="">
                <p>在线咨询</p>
            </a>
        </li>
        <li>
            <a href="tel:18980820575" target="_blank">
                <img src="/Public/Home/img/fot2.png" alt="">
                <p>拨打电话</p>
            </a>
        </li>
    </ul>
</div>
</body>
</html>
<script>
    $(".con 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>