• HTML5入门6---视频播放按钮


    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <title>第四个页面</title>
            <style>
                h1{
                    font-size: x-large;
                    margin: 6px 0px;
                }
                video{
                    border:double 8px lightgray;
                }
                .videoContainer{
                    max-width: 450px;
                }
                #postionBar{
                    height: 30px;
                    color:black;
                    font-weight: bold;
                    background: steelblue;
                    text-align: center;
                }
                #postionBar span{
                    display: inline-block;
                    width: 450px;
                    margin-bottom: 5px;
                }
                #durationBar{
                    border: solid 1px;
                    width: 450px;
                    margin-bottom: 5px;
                }
            </style>
            <script type="text/javascript">
                var video;
                var display;
                window.onload = function(){
                    video = document.getElementById("videoPlayer");
                    display = document.getElementById("displayStatus");
                    video.onplaying = function(){
                        display.innerHTML = "Playing......";
                    }
                    video.onpause = function(){
                        display.innerHTML = "Pausing......";
                    }
                }
                function progressUpdate(){
                    var postionBar = document.getElementById("postionBar");
                    postionBar.style.width = (video.currentTime/video.duration * 100) + "%";
                    display.innerHTML = Math.round((video.currentTime*100)/100) + "sec";
                }
                function play(){
                    video.play();
                }
                function pause(){
                    video.pause();
                }
                function stop(){
                    video.pause();
                    video.currentTime = 0;
                }
                function speedUp(){
                    video.play();
                    video.playbackRate = 2;
                }
                function slowDown(){
                    video.play();
                    video.playbackRate = 0.5;                
                }
                function normalSpeed(){
                                    video.play();
                    video.playbackRate = 1;    
                }
            </script>
        </head>
        
        <body>
        <div class="videoContainer">
            <video id="videoPlayer" ontimeupdate="progressUpdate()">
                <source src="resource/梦想.mp4" type="audio/mp4"></source>
            </video>
        </div>
                <div>
                    <div id="durationBar">
                        <div id="postionBar">
                            <span id="displayStatus"></span>
                        </div>
                    </div>
                </div>
                <button onclick="play()">Play</button>
                <button onclick="pause()">Pause</button>
                <button onclick="stop()">Stop</button>
                <button onclick="speedUp()">Fast</button>
                <button onclick="slowDown()">Slow</button>
                <button onclick="normalSpeed()">Normal</button>
        </body>
    </html>

     

  • 相关阅读:
    React.render和reactDom.render的区别
    CSS中position的4种定位详解
    React.js入门必须知道的那些事
    JS处理事件小技巧
    React.js深入学习详细解析
    React.js实现原生js拖拽效果及思考
    Linux ./configure && make && make install 编译安装和卸载
    Redis set集合结构及命令详解
    Redis数据过期策略
    Redis TTL命令
  • 原文地址:https://www.cnblogs.com/beautiful-code/p/5066096.html
Copyright © 2020-2023  润新知