New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

get-test-media

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-test-media

Generate a dummy MediaStream

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16
increased by45.45%
Maintainers
1
Weekly downloads
 
Created
Source

get-test-media

Generate a dummy MediaStream instance. This is useful for testing purposes where a media stream from getUserMedia is expected (e.g. in a RTCPeerConnection). This only works in modern browsers that support the Canvas.captureStream method.

npm install get-test-media

See the live demo.

Usage

The exported function accepts an options object somewhat similar to getUserMedia constraints (see example). It's also possible to pass a canvas element which will be used for drawing. Otherwise an element is created, attached to the body and hidden outside the screen by using absolute positioning.

var getTestMedia = require('get-test-media');

// Check if the browser supports the required APIs.
if(!getTestMedia.supported) console.error('Not supported');

var media = getTestMedia({
  audio: true,
  video: {
    width: 400,
    height: 300,
    frameRate: 24
  }
});

var pc = new RTCPeerConnection();
pc.addStream(media.stream);

// Cleanup when the stream is no longer in use.
media.close();

The object returned from getTestMedia has two properties. The stream property contains the MediaStream instance, while the close method cleans up the underlying resources and should be called when the stream is no longer in use.

Keywords

FAQs

Package last updated on 09 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc