长沙网站推广和优化,招远网站建设价格,安康网站建设公司价格,绍兴网站公司网站制作uniapp开发app并没有相关Api调用前置摄像头。只能使用5app的api
调用前置摄像头拍照
plus.camera.getCamera(index)
获取需要操作的摄像头对象#xff0c;如果要进行拍照或摄像操作#xff0c;需先通过此方法获取摄像头对象
index指定要获取摄像头的索引值#xff0c;1表…uniapp开发app并没有相关Api调用前置摄像头。只能使用5app的api
调用前置摄像头拍照
plus.camera.getCamera(index)
获取需要操作的摄像头对象如果要进行拍照或摄像操作需先通过此方法获取摄像头对象
index指定要获取摄像头的索引值1表示主摄像头2表示辅摄像头。如果没有设置则使用系统默认主摄像头。
takePhoto() {let camera plus.camera.getCamera(2);var res camera.supportedImageResolutions[0];var fmt camera.supportedImageFormats[0];camera.captureImage((res) {plus.io.resolveLocalFileSystemURL(res, (entry) {this.uploadFile(entry)});}, (err) {console.log(err)}, {resolution: res,format: fmt})},uploadFile(entry) {console.log(entry)var uploadUrl https://; // 替换为你的上传接口var uploadTask plus.uploader.createUpload(uploadUrl, {method: POST}, function(t, status) {console.log(t,status)// 上传完成if (status 200) {console.log(上传成功: t.responseText);} else {console.log(上传失败: t.status);}});uploadTask.addFile(entry.toLocalURL(), {key: image});uploadTask.start();}