Coder Social home page Coder Social logo

theopenwebjp / get-user-media-mock Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 13.72 MB

Mock library for getUserMedia and related functions.

Home Page: https://theopenweb.info/app/get-user-media-mock/index.html

License: MIT License

HTML 38.39% JavaScript 61.61%
getusermedia mock-library navigator javascript

get-user-media-mock's Introduction

Description

Mock library for getUserMedia and related functions.

Installation

npm install @theopenweb/get-user-media-mock

Usage

The code below will automatically apply mocks to the following functions:

  • navigator.getUserMedia
  • navigator.mediaDevices.getUserMedia
  • navigator.mediaDevices.enumerateDevices
  • navigator.mediaDevices.getSupportedConstraints
window.getUserMediaMock = new GetUserMediaMock();
getUserMediaMock.mock();

The code below will only apply mock stream if getUserMedia function(navigator.getUserMedia OR navigator.mediaDevices.getUserMedia) results in an error.

window.getUserMediaMock = new GetUserMediaMock();
getUserMediaMock.fallbackMock();

For more advanced usage check [Functions].

Functions

All functions below are on the main instance. Type information uses TypeScript format. Types can be searched in the repository.

  • setMediaUrl (url: string)
  • setMockType (mockType: MockType)
  • fallbackMock ()
  • mock (options: MockOptions)
  • restoreOldHandles ()
  • getMockStreamFromConstraints
  • getMockCanvasStream (constraints: MediaStreamConstraints)
  • getMockMediaElementStream (constraints: MediaStreamConstraints)
  • createStartedRandomCanvasDrawerInterval (canvas: HTMLCanvasElement)
  • getConstraintBestValue (constraints: MediaStreamConstraints, type: MediaStreamTrackType, key: keyof MediaTrackConstraints)
  • getMockDevices ()

Support

Polyfills and transpiling(Babel, etc.) should be done outside of this library.

Dependencies

Test

npx http-server ./
# http://localhost:8080

Test Media

Test Media are included for testing AND possibly mocking. These media are not heavily depended on, so can be changed or removed if important. If using build tools, the sizes should not be an issue. If there is an issue when building please contact.

get-user-media-mock's People

Contributors

theopenwebjp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.