Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A little library for integrating webcam video and microphone audio into your app.
JavaScript CSS
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
LICENSE
readme.md
sound-and-vision.js
sound-and-vision.min.js

readme.md

Sound And Vision

A little library for integrating webcam video and microphone audio into your app.

Like Say Cheese, but smaller and built with extensibility in mind.

Setup

Grab the JS, host it, and add it to your page. For example:

<script src='/assets/js/sound-and-vision.js'></script>

Usage

Sound and Vision wraps getUserMedia and gives you back a Promise.

var soundAndVision = new SoundAndVision('#container-element', { audio: true, video: true });

soundAndVision.start()
  .then(doSomethingWithCameraOrMic)
  .catch(handleErrors)

If all goes well, and the camera or mic are enabled, you're given direct access to the video and audio streams:

soundAndVision.start().then(function (media) { // media == soundAndVision
  media.video         // do something with the video element
  media.audio.stream  // do something with the audio stream
  media.audio.context // do something with the audio context
})

From here you're free to do whatever you like. You can take snapshots by rendering a frame of the video to a canvas, record clips of video or audio and save them to disk, or go crazy and explore all the other things you can do with a canvas, webGL, and the WebAudio API.

Stopping the show

There's also a function to stop the webcam after loading it up:

soundAndVision.stop()

Audio support

Audio's disabled by default, because it doesn't have full browser support. You can still enable it for browsers that do support it, though. Just set audio to true when setting up.

var soundAndVision = new SoundAndVision('#container-element', { audio: true })

This will request access to the microphone, and will pipe the audio through to your output device.

This is supported in:

  • Google Chrome
  • Firefox 25+
  • Latest Opera

Compatibility

Tested and verified to work in:

  • Firefox
  • Google Chrome
  • Opera

Why use this and not Say Cheese?

If you only care about getting a webcam or mic up and running on your site, then this is for you. If you actually want snapshot functionality, and don't want to write it yourself, then go grab that.

License

Copyright (C) 2012-2014 Lee Machin

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.

Something went wrong with that request. Please try again.