码迷,mamicode.com
首页 > Web开发 > 详细

html5-voideo_DOM

时间:2020-03-29 01:18:14      阅读:306      评论:0      收藏:0      [点我收藏+]

标签:document   ice   func   text   css   color   class   else   type   

HTML5 <video> - 使用 DOM 进行控制

为视频创建简单的播放/暂停以及调整尺寸控件:

代码如下:

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <style type="text/css">
        .box{
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="box">
        <button onclick="playPase()">播放/暂停</button>
        <button onclick="makeBig()"></button>
        <button onclick="makeNormal()"></button>
        <button onclick="makeSmall()"></button>
        <br>
        <video id="video1" width="420" style="margin-top: 15px;">
            <source src="video/despacito.mp4" type="video/mp4">
            <source src="video/despacito.ogg" type="video/video/ogg">
        </video>
    </div>
    <script type="text/javascript">
        var Ovideo=document.getElementById("video1");
        function playPase(){
            if(Ovideo.pause){
                Ovideo.play();
            }else{
                Ovideo.pause();
            }
        }
        
        function makeBig(){ 
            Ovideo.width=560; 
        } 
        
        function makeSmall(){ 
            Ovideo.width=320; 
        } 
        
        function makeNormal(){ 
            Ovideo.width=420; 
        } 
    </script>
</body>
</html>

运行结果如图

技术图片

 

html5-voideo_DOM

标签:document   ice   func   text   css   color   class   else   type   

原文地址:https://www.cnblogs.com/sad-dog/p/12590285.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!