Standard media contraint for exact deviceId not working
See original GitHub issueI am trying to create a simple Livestream implementation. Everything works fine on the Web (Chrome Browser) but there is no way to choose a specific media device on react-native.
I have tried different variants of the constraint implementations but none worked.
I am testing on Android (6.0 Marshmallow real device debug mode) and react-native-webrtc 1.75.0. My react-native version is 0.60.5 and react version is 16.8.6
import {mediaDevices} from 'react-native-webrtc';
// mediaDevices.enumerateDevices returns one audio deviceId 'audio-1'
// and two video deviceIds '0' and '1'
mediaDevices.getUserMedia({
// Tried 'audio-1' but crashed the app so I removed it
audio: true,
// Tried both '0' and '1' but returns only the front camera no matter what
video: {deviceId: {exact: '1'}},
}).then((stream) => {
// Always returns the front camera for both '0' and '1'.
console.log(stream);
}).catch((reason) => {
// There is no error
console.log(reason);
});
Is it impossible to choose a specific camera and microphone with react-native-webrtc?
- React Native version: 0.60.5
- Plugin version: 1.75.0
- OS: Android
- OS version: 6.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
MediaTrackConstraints.deviceId - Web APIs - MDN Web Docs
An object based on ConstrainDOMString specifying one or more acceptable, ideal, and/or exact (mandatory) device IDs which are acceptable as the ...
Read more >What constraints should I pass to getUserMedia() in order to ...
The exact keyword makes the constraint required, guaranteeing it'll return only the right one, or fail. If you want two cameras, you'll have...
Read more >Getting started with media devices - WebRTC
API first check the existing devices and then specifies a constraint that matches the exact device using the deviceId constraint. Devices will ...
Read more >Media Capture and Streams - W3C
It also exposes information about devices able to capture and render media. ... Sources do not have constraints — tracks have constraints.
Read more >getUserMedia resolutions III - constraints unleashed
I discovered that working with getUserMedia constraints was not all that straight ... or if you are dealing with non-standard video devices.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Firstly let me explain how i do tests i use 2 Android device one of them connected with wired_headphone other one not when i used incall manager with route option it works i can use headphone`s mic but sound is very low when i check with other device and when i plugged out and tested with device default mic sound volume level is good so there is problem with using headphone mic i tested with different headphones but result is same i also tested with different libraries like react-native-switch-audio-output also result is same any advice ?
You need some package line React-native-incall-manager to change audio routes.