zoukankan      html  css  js  c++  java
  • canvas 点击图片播放视频

    canvas.js

    window.onload=function() {
        var canvas = document.getElementById('canvas');
    
        var ctx= canvas.getContext('2d');
    
        
         var img=document.getElementsByTagName('img')[0];
         ctx.drawImage(img,0,0,200,200);
         var video=document.getElementById('video');
         canvas.onclick=function() {
             video.play();
             video.addEventListener("play", function () {
                   setInterval(function() {
                       ctx.drawImage(video,0,0,200,200);
    
                   },20);
             });
         }
    };
    

      canvas.html

    <!DOCTYPE HTML>
    <html>
    <head>
        <meta charset="utf-8">
        <title>实例</title>
        <script  type="text/javascript"  src="canvas1.js"></script>
        <style>
            canvas {
                background: #eeeeee;
            }
        </style>
    </head>
    <body>
    <canvas id="canvas" width="500" height="500"></canvas>
    
    <img  src="不二.jpg"  hidden >
    <video  src="陈奕迅 - 陪你度过漫长岁月.mp4"  id="video" hidden>
    </video>
    </body>
    </html>
    

      效果:

    2017-09-11  13:21:15

  • 相关阅读:
    HOW TO MAKE IT FLOW ?
    ansys14.0 从入门到精通
    ansys 14.0
    C++ GUI Qt4 编程 (第二版)
    零基础学QT编程
    医学成像与医学图像处理
    曾巩传
    c++ 编程调试秘笈
    matlab实用教程
    不要重复发明轮子-C++STL
  • 原文地址:https://www.cnblogs.com/guangzhou11/p/7504537.html
Copyright © 2011-2022 走看看