zoukankan      html  css  js  c++  java
  • JS_0025:Promise 异步编程

    1,

        listCamera(videoDevice) {
            return new Promise((resolve, reject) => {
                navigator.mediaDevices.enumerateDevices()
                    .then((devices) => {
                    let index = 1;
                    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++;
                            }
                            else {
                                option.text = device.label || 'camera ' + (videoDevice.length + 1).toString();
                                option.value = JSON.stringify({ audio: false, video: { deviceId: { exact: device.deviceId } } });
                            }
                            // 将摄像头信息存储在select元素中,方便切换前、后置摄像头
                            videoDevice.appendChild(option);
                        }
                        return false;
                    });
                    if (videoDevice.length === 0) {
                        console.log("list1");
                        reject('没有可使用的视频设备');
                    }
                    else {
                        this.initVideo();
                        this.initCanvas();
                        resolve(true);
                    }
                }).catch(err => {
                    reject(err);
                });
            });
        }






     

     

     

     

     

     

     

    琥珀君的博客
  • 相关阅读:
    软件工程第四周进度总结
    djang-模型层(model)--添加,查询,修改
    django--模型层(ORM)-建表
    django---模板层
    django--MTV基础模型
    django--权限管理思路版
    django--权限管理day1
    django-超级管理员操作
    django-orm的表操作.
    django---查询操作
  • 原文地址:https://www.cnblogs.com/eliteboy/p/13530252.html
Copyright © 2011-2022 走看看