cristiandouce / camera-action

Camera-action is a component to ease camera (getusermedia) management.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Camera-action

Camera-action is a component to ease camera (getusermedia) management.

It's cross-browser compatible:

  • Firefox
  • Google Chrome
  • Opera

Note: getUserMedia has to be enabled in Firefox by setting the media.peerconnection.enabled option to true in about:config.

Installation

$ component install pazguille/camera-action

See: https://github.com/component/component

Standalone

Also, you can use the standalone version:

<script src="../standalone/camera-action.js"></script>

How-to

First, defines the camera's container and its options (see the API):

var container = document.querySelector('#container'),
    options = {
        'width': 640,
        'height': 480
    };

Now, requires and creates a new instance of camera-action:

var Camera = require('camera-action'),
    camera = new Camera(container, options);

Then, starts to use it!:

camera.action();

Camera... Action!

API

Camera#action()

Adds the camera to its container and starts to record.

camera.action();

Camera#pause()

Pause the camera.

camera.pause();

Camera#takePhoto() [WIP]

Takes a snapshot from the camera.

camera.takePhoto();

Camera#cut()

Removes the camera from its container.

camera.cut();

options

  • width: (number) The size width of the camera. The default value is 320.
  • height: (number)The size height of the camera. The default value is 240.
  • hd: (boolean) Turn on HD to capture in 720p (works only in Chrome). The default value is false.

### Events [WIP]

  • action: emitted when the camera is started.
  • pause: emitted when the camera is paused.
  • cut: emitted when the camera is removed.
  • photo: emitted when the camera take a photo.

Contact

License

### The MIT License Copyright (c) 2012 @pazguille

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Camera-action is a component to ease camera (getusermedia) management.