zoukankan      html  css  js  c++  java
  • 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>

     

  • 相关阅读:
    java多线程(同步与死锁问题,生产者与消费者问题)
    剑指OFFER之跳台阶(九度OJ1388)
    剑指OFFER之二维数组中的查找(九度OJ1384)
    剑指OFFER之旋转数组的最小数字(九度OJ1386)
    我所思考的生活,致半年后的自己
    剑指OFFER之用两个栈实现队列(九度OJ1512)
    剑指OFFER之二维数组中的查找(九度OJ1384)
    剑指OFFER之重建二叉树(九度OJ1385)
    简单的客户机服务器投射模拟
    网络复习之TCP
  • 原文地址:https://www.cnblogs.com/beautiful-code/p/5066096.html
Copyright © 2011-2022 走看看