亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

js+HTML5實(shí)現(xiàn)視頻截圖的方法

 更新時(shí)間:2015年06月16日 12:18:23   作者:紅薯  
這篇文章主要介紹了js+HTML5實(shí)現(xiàn)視頻截圖的方法,涉及javascript操作html5元素實(shí)現(xiàn)多媒體文件截圖的相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了js+HTML5實(shí)現(xiàn)視頻截圖的方法。分享給大家供大家參考。具體如下:

1. HTML部分:

<video id="video" controls="controls">
  <source src=".mp4" />
</video>
<button id="capture">Capture</button>
<div id="output"></div>

2. 點(diǎn)擊按鈕時(shí)觸發(fā)如下代碼:

(function() {
  "use strict";
  var video, $output;
  var scale = 0.25;
  var initialize = function() {
    $output = $("#output");
    video = $("#video").get(0);
    $("#capture").click(captureImage);        
  };
  var captureImage = function() {
    var canvas = document.createElement("canvas");
    canvas.width = video.videoWidth * scale;
    canvas.height = video.videoHeight * scale;
    canvas.getContext('2d')
       .drawImage(video, 0, 0, canvas.width, canvas.height);
    var img = document.createElement("img");
    img.src = canvas.toDataURL();
    $output.prepend(img);
  };
  $(initialize);      
}());

希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論