ios端使用webar德莫找不到后置摄像头

0 投票
最新提问 10月 22, 2020 用户: lingqi (120 分)
ios端在safari浏览器只能找到前置摄像头,后置摄像头找不到。

android端则没有出现后置摄像头找不到的问题,如何解决。

navigator.mediaDevices.enumerateDevices()

                .then((devices) => {

                let index = 0;

                let lastOptionValue;

                

                devices.find((device) => {

                    if (device.kind === 'videoinput') {

                        const option = document.createElement('option');

                        // 在iOS12.2上deviceId为空

                        if (device.deviceId == '') {

                            option.text = device.label || 'camera ' + this.cameras[index];

                            option.value = JSON.stringify({ audio: false, video: { facingMode: { exact: this.cameras[index] } } });

                            index++;

                        

                        lastOptionValue = option.value;

                        }

                        else {

                            option.text = device.label || 'camera ' + (videoDevice.length + 1).toString();

                            option.value = JSON.stringify({ audio: false, video: { deviceId: { exact: device.deviceId } } });

                            

                            lastOptionValue = option.value;

                        }

                        

                        // 将摄像头信息存储在select元素中,方便切换前、后置摄像头

                        videoDevice.prepend(option);

                        

                        //videoDevice.options[1].selected = true;

                    }

                    return false;

                });

                

                videoDevice.value = lastOptionValue;

                

                if (videoDevice.length === 0) {

                    reject('没有可使用的视频设备');

                }

                else {

                    this.initVideo();

                    this.initCanvas();

                    resolve(true);

                }

            }).catch(err => {

                reject(err);

            });

1个回答

0 投票
最新回答 11月 9, 2020 用户: liisay2020 (180 分)
还没解决吗?加我QQ吧,251669603  我告诉你怎么操作
欢迎来到 EasyAR Q&A ,有什么不懂的可以尽管在这里提问,你将会收到社区其他成员的回答。
...