Comparing version 1.0.0 to 1.0.2
var snapstream = require('..'); | ||
var getUserMedia = require('getusermedia'); | ||
var kgo = require('kgo'); | ||
var h = require('hyperscript'); | ||
kgo({ | ||
constraints: { video: true, audio: true } | ||
constraints: { video: true, audio: false } | ||
}) | ||
@@ -12,3 +13,4 @@ ('capture', ['constraints'], getUserMedia) | ||
console.log('got image data: ', imageData, imageData.length); | ||
document.body.appendChild(h('img', { src: imageData })); | ||
}) | ||
.on('error', console.error.bind(console)); |
20
index.js
@@ -6,2 +6,3 @@ var attach = require('rtc-attach'); | ||
var canplay = require('canplay'); | ||
var snapvid = require('snapvid'); | ||
@@ -32,22 +33,5 @@ /** | ||
('capture', ['renderable'], function(video) { | ||
var canvas = getCachedCanvas(video); | ||
var context = canvas.getContext('2d'); | ||
context.drawImage(video, 0, 0); | ||
callback(null, canvas.toDataURL('image/jpeg')); | ||
callback(null, snapvid(video, opts)); | ||
}) | ||
.on('error', callback); | ||
}; | ||
function getCachedCanvas(video) { | ||
var key = video.videoWidth + '|' + video.videoHeight; | ||
var canvas = _cached[key]; | ||
if (! canvas) { | ||
canvas = _cached[key] = document.createElement('canvas'); | ||
canvas.width = video.videoWidth; | ||
canvas.height = video.videoHeight; | ||
} | ||
return canvas; | ||
} |
{ | ||
"name": "snapstream", | ||
"version": "1.0.0", | ||
"version": "1.0.2", | ||
"description": "Capture base64 image data for an input MediaStream containing video track information", | ||
@@ -28,7 +28,9 @@ "main": "index.js", | ||
"kgo": "^1.2.0", | ||
"rtc-attach": "^1.2.1" | ||
"rtc-attach": "^1.2.1", | ||
"snapvid": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"getusermedia": "^1.0.0" | ||
"getusermedia": "^1.0.0", | ||
"hyperscript": "^1.4.3" | ||
} | ||
} |
@@ -17,5 +17,6 @@ # snapstream | ||
var kgo = require('kgo'); | ||
var h = require('hyperscript'); | ||
kgo({ | ||
constraints: { video: true, audio: true } | ||
constraints: { video: true, audio: false } | ||
}) | ||
@@ -26,2 +27,3 @@ ('capture', ['constraints'], getUserMedia) | ||
console.log('got image data: ', imageData, imageData.length); | ||
document.body.appendChild(h('img', { src: imageData })); | ||
}) | ||
@@ -36,3 +38,3 @@ .on('error', console.error.bind(console)); | ||
Copyright (c) 2014 Damon Oehlman <damon.oehlman@gmail.com> | ||
Copyright (c) 2015 Damon Oehlman <damon.oehlman@gmail.com> | ||
@@ -39,0 +41,0 @@ Permission is hereby granted, free of charge, to any person obtaining |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56
3986
5
2
43
+ Addedsnapvid@^1.0.0
+ Addedsnapvid@1.0.0(transitive)