From bceab2315c3a0704ce0d933e2a47c4ef3940fef3 Mon Sep 17 00:00:00 2001 From: Benjamin RICHARD Date: Thu, 11 Feb 2016 14:43:09 +0100 Subject: [PATCH 1/3] provide a way to get access to photo content and to call closeAndCallback function to allow the template remove from DOM It also add a way to specify options using Meteor.settings.public.Meteor.Camera : { camera: {type: "front"/"back", width: 640, height: 480, quality: 80, viewFinder: {width: 320, height: 240}} --- packages/mdg:camera/photo-browser.js | 179 +++++++++++++++++++++------ packages/mdg:camera/photo.html | 166 ++++++++++++------------- packages/mdg:camera/photo.js | 67 +++++++++- 3 files changed, 291 insertions(+), 121 deletions(-) diff --git a/packages/mdg:camera/photo-browser.js b/packages/mdg:camera/photo-browser.js index b54cead..7b130d1 100644 --- a/packages/mdg:camera/photo-browser.js +++ b/packages/mdg:camera/photo-browser.js @@ -1,5 +1,35 @@ -var stream; -var closeAndCallback; +// merge defaults settings with Meteor settings if exists +var settings = (function(defaults) { + var settings = + { + camera: { + type: "back", + width: 640, + height: 480 + }, + quality: 80, + viewFinder: { + width: 320, + height: 240 + } + }; + + if (!defaults) return settings; + + if (defaults.camera) { + settings.camera = _.extend(settings.camera, defaults.camera); + } + + if (defaults.quality && check(defaults.quality, Number)) { + settings.quality = defaults.quality; + } + + if (defaults.viewFinder) { + settings.viewFinder = _.extend(settings.viewFinder, defaults.viewFinder); + } + + return settings; +})(Meteor.settings.public.MeteorCamera); var photo = new ReactiveVar(null); var error = new ReactiveVar(null); @@ -8,9 +38,7 @@ var waitingForPermission = new ReactiveVar(null); var canvasWidth = 0; var canvasHeight = 0; -var quality = 80; - -Template.viewfinder.rendered = function() { +Template.viewfinder.onRendered(function() { var template = this; waitingForPermission.set(true); @@ -19,13 +47,13 @@ Template.viewfinder.rendered = function() { // stream webcam video to the