Creates mock for getUserMedia so can use without Webcam.
npm install @theopenweb/get-user-media-mocknpm install @theopenweb/get-user-media-mock
javascript
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.
`javascript
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.
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/captureStream
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/captureStream
Dependencies
* https://github.com/meenie/band.js
Test
`bash
npx http-server ./
http://localhost:8080
``