利用純客戶端JavaScript實現屏幕錄制和截屏:JSCapture

jopen 10年前發布 | 98K 次閱讀 JSCapture 常用工具包

JSCapture一個基于純 JavaScript與HTML5實現的截屏庫。
它可以讓你從瀏覽器做您在桌面的截圖和視頻錄制。JSCapture使用getUserMedia捕獲屏幕。目前的屏幕捕捉API僅支持通過谷歌Chrome,和實際標志的Canary與Chromium。

API

  • JSCapture.capture(config) - Captures a new screenshot.
    • config.x - (Number) default value 0. Specifies the left offset.
    • config.y - (Number) default value 0. Specifies the top offset.
    • config.width - (Number) default value the screen width. Specifies the width of the screenshot.
    • config.height - (Number) default value the screen height. Specifies the height of the screenshot.
    • config.process - (Function|Array) default value an empty array. A list of filters, which are going to process the image.
    • config.done - (Function) default value is undefined. Callback, which is being called with the captured image.
    • config.fail - (Function) default value is undefined. A callback, which is being executed on unsuccessful screen capturing (for example if the user does not allow screen capturing).
    • config.delay - (Number) default value 0. Specifies the delay after each the screenshot will be captured.
  • JSCapture.record(config) - Capture a video.
    • config.x - (Number) default value 0. Specifies the left offset.
    • config.y - (Number) default value 0. Specifies the top offset.
    • config.width - (Number) default value the screen width. Specifies the width of the video.
    • config.height - (Number) default value the screen height. Specifies the height of the video.
    • config.process - (Function|Array) default value an empty array. A list of filters, which are going to process the individual frames.
    • config.done - (Function) default value is undefined. Callback, which is being called with the captured video.
    • config.delay - (Number) default value 0. Specifies the delay after each the video will be captured.
    • config.frameRate - (Number) default value 60 frames per second. Specifies the number of frames per second.
    • config.done - (Function) default value is undefined. A callback, which accepts the video (as a Blob), result of the screen recording, as an argument
    • config.fail - (Function) default value is undefined. A callback, which is being executed on unsuccessful screen recording (for example if the user does not allow screen capturing).
    • config.duration - (Number) default is Infinity. A number which indicates the length of the video.
  • JSCapture.stopRecording(fn) - Stops the video recording.
    • fn - (Function) default value is undefined. A callback, which accepts the video (as a Blob), result of the screen recording, as an argument. Note that the callback provided in config.done won't be invoked if JSCapture.stopRecording(fn) is called.
  • JSCapture.isRecording() - (Boolean) Returns whether the screen recording have been started.

項目主頁:http://www.baiduhome.net/lib/view/home/1400817809878

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!