zoukankan      html  css  js  c++  java
  • Html5——视频标签使用

    video标签:

    上面的例子使用一个 Ogg 文件,适用于Firefox、Opera 以及 Chrome 浏览器。
    要确保适用于 Safari 浏览器,视频文件必须是 MPEG4 类型。
    video 元素允许多个 source 元素。source 元素可以链接不同的视频文件。浏览器将使用第一个可识别的格式

    preload 属性规定是否在页面加载载入视频。

    实例:

    1、

    <!DOCTYPE HTML>
    <html>
    <body>
    <video width="320" height="240" controls="controls">
    <source src="http://www.w3school.com.cn/i/movie.ogg" type="video/ogg">
    <source src="http://www.w3school.com.cn/i/movie.mp4" type="video/mp4">
    您的浏览器不支持Html5标签 video tag.
    </video>
    </body>
    </html>

    2、事件、方法、属性

    <div style="text-align: center;">
    <button onclick="playPause()">播放/暂停</button>
    <button onclick="makeBig()">大</button>
    <button onclick="makeNormal()">中</button>
    <button onclick="makeSmall()">小</button>
    <video id="video1" width="420" style="margin-top: 15px">
    <source src="/example/html5/mov_bbb.mp4" type="video/mp4">
    <source src="/example/html5/mov_bbb.ogg" type="video/ogg">
    您的浏览器不支持html5 video 标签
    </video>
    </div>
    <script type="text/javascript">
    var myVideo = document.getElementById("video1");
    function playPause() {
    if (myVideo.paused) {
    myVideo.play();
    } else {
    myVideo.pause();
    }
    }
    function makeBig() {
    myVideo.width = "560";

    }
    function makeSmall() {
    myVideo.width = "320";
    }
    function makeNormal() {
    myVideo.width = "420";
    }
    </script>

    HTML5 <video> - 方法、属性以及事件

    下面列出了大多数浏览器支持的视频方法、属性和事件:

    方法属性事件
    play() currentSrc play
    pause() currentTime pause
    load() videoWidth progress
    canPlayType videoHeight error
      duration timeupdate
      ended ended
      error abort
      paused empty
      muted emptied
      seeking waiting
      volume loadedmetadata
      height  
      width  

    注释:在所有属性中,只有 videoWidth 和 videoHeight 属性是立即可用的。在视频的元数据已加载后,其他属性才可用。

  • 相关阅读:
    获得插入记录标识号, 鼠标移到DataGrid的行更改颜色(转)
    ESRI ArcGIS 9.0系列软件报价(转)
    世界电子地图
    Microsoft’s.NET MicroFramework初接触
    MapServer初体验成功
    MapScript C# Tutorial Programming MapServer in the ASP .NET Framework(转)
    WPF 中的Width 与 ActualWidth
    可空值类型
    面试时遇到上机编程题
    checked、unchecked
  • 原文地址:https://www.cnblogs.com/Defry/p/4309309.html
Copyright © 2011-2022 走看看