Merge pull request #6985 from gustavotrott/ios-webcam-list-problem
Change webcam resolution to 640x480 if using iOS
This commit is contained in:
commit
c0c4ce77c2
@ -156,14 +156,9 @@ class VideoPreview extends Component {
|
||||
const webcams = [];
|
||||
|
||||
// set webcam
|
||||
if (webcamDeviceId) {
|
||||
changeWebcam(webcamDeviceId);
|
||||
this.setState({ webcamDeviceId });
|
||||
isInitialDeviceSet = true;
|
||||
}
|
||||
devices.forEach((device) => {
|
||||
if (device.kind === 'videoinput') {
|
||||
if (!isInitialDeviceSet) {
|
||||
if (!isInitialDeviceSet || (webcamDeviceId && webcamDeviceId === device.deviceId)) {
|
||||
changeWebcam(device.deviceId);
|
||||
this.setState({ webcamDeviceId: device.deviceId });
|
||||
isInitialDeviceSet = true;
|
||||
@ -175,6 +170,14 @@ class VideoPreview extends Component {
|
||||
}
|
||||
|
||||
constraints.video.deviceId = { exact: this.state.webcamDeviceId };
|
||||
|
||||
const iOS = ['iPad', 'iPhone', 'iPod'].indexOf(navigator.platform) >= 0;
|
||||
|
||||
if (iOS) {
|
||||
constraints.video.width = { max: 640 };
|
||||
constraints.video.height = { max: 480 };
|
||||
}
|
||||
|
||||
navigator.mediaDevices.getUserMedia(constraints).then((stream) => {
|
||||
// display the preview
|
||||
this.video.srcObject = stream;
|
||||
|
Loading…
Reference in New Issue
Block a user