zoukankan      html  css  js  c++  java
  • Html视频播放同时获取当前帧下的图片

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>W3CSchool Demo</title>
    </head>
    <body>
        <video id="video1" controls="" width="270" style="margin-top:15px;">
              <source src="demo/video1.mp4" type="video/mp4">
              <!-- <source src="/example/html5/mov_bbb.ogg" type="video/ogg">
              <source src="/example/html5/mov_bbb.webm" type="video/webm"> -->
        </video>
        <canvas id="myCanvas4" width="270" height="135" style="border:1px solid #d3d3d3; margin-top:15px;">
            Your browser does not support the HTML5 canvas tag.
        </canvas>
        <script>
            var v=document.getElementById("video1");
            var c=document.getElementById("myCanvas4");
            ctx=c.getContext('2d');
    
            v.addEventListener('play', function() {var i=window.setInterval(function() {ctx.drawImage(v,0,0,270,135)},20);},false);
            v.addEventListener('pause',function() {window.clearInterval(i);},false);
            v.addEventListener('ended',function() {clearInterval(i);},false);
        </script>
    </body>
    </html>

    参考W3CSchool:http://www.w3school.com.cn/tags/canvas_drawimage.asp

  • 相关阅读:
    数据对象映射模式
    策略模式
    适配模式
    注册模式
    单例模式
    工厂模式
    PHP魔法方法的使用
    【转】通过 ulimit 改善系统性能
    HDMI相关知识
    中国三种3G网络频段
  • 原文地址:https://www.cnblogs.com/ifindu-san/p/7112470.html
Copyright © 2011-2022 走看看