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 属性是立即可用的。在视频的元数据已加载后,其他属性才可用。

  • 相关阅读:
    swing_AbstractTableModel 创建表格
    swing_tableModel 创建表格
    LDA主题模型
    jieba分词
    LightGBM介绍及参数调优
    机器学习中常见的损失函数
    const和define区别 static
    C++四种类型转换
    行为模式->策略模式
    结构模式->享元模式
  • 原文地址:https://www.cnblogs.com/Defry/p/4309309.html
Copyright © 2011-2022 走看看