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>

     

  • 相关阅读:
    Eclipse OSBP 设置 配置
    限制文本框输入的内容
    jquery 操作iframe的几种方法总结
    利用PLUPLOAD上传大文件
    oracle contains
    JSON.parse
    js正则表达式replace里有变量的解决方法用到RegExp类
    Web API WinForm使用HttpClient呼叫Web API
    JQUERY DIALOG窗格内不能使用FORM
    Access forbidden! XAMPP虚拟主机的问题
  • 原文地址:https://www.cnblogs.com/beautiful-code/p/5066096.html
Copyright © 2011-2022 走看看