Skip to content

Instantly share code, notes, and snippets.

@LFSCamargo
Last active June 21, 2019 22:41
Show Gist options
  • Save LFSCamargo/df2095d806119a97613e5bc37a5e9fdf to your computer and use it in GitHub Desktop.
Save LFSCamargo/df2095d806119a97613e5bc37a5e9fdf to your computer and use it in GitHub Desktop.
MediaStreamTrack.getSources((sourceInfos)) => {
console.log('MediaStreamTrack.getSources', sourceInfos)
let videoSourceId
for (let i = 0; i < sourceInfos.length; i++) {
const sourceInfo = sourceInfos[i]
if (sourceInfo.kind === 'video' && sourceInfo.facing === 'front') {
videoSourceId = sourceInfo.id
}
}
getUserMedia(
{
audio: true,
video: {
mandatory: {
// here you pass the resolutions and the
// minimun frame rate for the video
minWidth: 1280,
minHeight: 720,
minFrameRate: 30,
},
// here you can choose the camera mode `environment` and `user`
facingMode: 'user',
optional: videoSourceId ? [{ sourceId: videoSourceId }] : [],
},
},
(receivedStream: any) => {
// run a pc.addStream() and pass the receivedStream as a param
// store the stream on the localstate display on a <RTCView />
},
e => {
// Tracking Errors
},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment