startMediaStream(captureAudio, width, height) → {Phaser.Video}
Instead of playing a video file this method allows you to stream video data from an attached webcam.
As soon as this method is called the user will be prompted by their browser to "Allow" access to the webcam.
If they allow it the webcam feed is directed to this Video. Call Video.play
to start the stream.
If they block the webcam the onError signal will be dispatched containing the NavigatorUserMediaError
or MediaStreamError event.
You can optionally set a width and height for the stream. If set the input will be cropped to these dimensions.
If not given then as soon as the stream has enough data the video dimensions will be changed to match the webcam device.
You can listen for this with the onChangeSource signal.
Parameters
Name | Type | Argument | Default | Description |
---|---|---|---|---|
captureAudio | boolean | <optional> | false | Controls if audio should be captured along with video in the video stream. |
width | integer | <optional> | The width is used to create the video stream. If not provided the video width will be set to the width of the webcam input source. | |
height | integer | <optional> | The height is used to create the video stream. If not provided the video height will be set to the height of the webcam input source. |
Returns
This Video object for method chaining or false if the device doesn't support getUserMedia.
- Source code: gameobjects/Video.js (Line 337)
Please login to continue.