H5移动端调用底层接口的一些使用方法-01调用系统的摄像头
来源:互联网 发布:java aes 32位key 编辑:程序博客网 时间:2024/05/17 06:55
webApp迅速的发展,各种跨平台框架如雨后春笋般的成倍增长着;使用H5去开发跨平台APP,经常会遇到调用系统底层接口的一些问题:如摄像头、拍照、支付、打电话、短信等等一系列功能,这里简单介绍一部分,以后会持续更新;
1. H5 调用本地摄像头
plus.camera.getCamera( index );
index可取1、2。
1代表主摄像头 2代表副摄像头,方法返回一个摄像头的管理对象Camera。
Camera的静态属性:
① Camera.supportedImageResolutions: 字符串数组,摄像头支持的拍照分辨率
② Camera.supportedVideoResolutions: 字符串数组,摄像头支持的摄像分辨率
③ Camera.supportedImageFormats: 字符串数组,摄像头支持的拍照文件格式
④ Camera.supportedVideoFormats: 字符串数组,摄像头支持的摄像文件格式
Camera的方法:
①Camera.captureImage( successCB, errorCB, option );调用摄像头进行拍照动作
successCB(capturedFile ):调用摄像头操作成功的回调函数,在拍照或摄像操作成功时调用,用于返 回图片或视频文件的路径capturedFile 。
errorCB:调用摄像头操作失败的回调函数。
option :拍照的拓展参数 filename:拍照文件保存的路径、format:拍照的文件格式、index拍照默认使用的摄像头、popover拍照或摄像界面弹出指示区域(top,left….);
②Camera.startVideoCapture( successCB, errorCB, option );调用摄像头进行摄像操作
successCB(capturedFile ):调用摄像头进行摄像操作成功的回调函数,用于返回视频文件的路径capturedFile 。
errorCB:调用摄像头操作失败的回调函数。
option :摄像的拓展参数 filename:拍照文件保存的路径、format:拍照的文件格式、index拍照默认使用的摄像头、popover拍照或摄像界面弹出指示区域(top,left….);
③Camera.stopVideoCapture(); 结束摄像动作
代码测试: //只有在 plus ready之后才能调用plus api if(window.plus) { plusReady(); } else { document.addEventListener("plusready", plusReady, false); } function plusReady() { var camera = plus.camera.getCamera( 1 ); //获取摄像头管理对象 // 字符串数组,摄像头支持的拍照分辨率 var supportedImageResolutions = camera.supportedImageResolutions; // 字符串数组,摄像头支持的摄像分辨率 var supportedVideoResolutions = camera.supportedVideoResolutions; // 字符串数组,摄像头支持的拍照文件格式 var supportedImageFormats = camera.supportedImageFormats; // 字符串数组,摄像头支持的摄像文件格式 var supportedVideoFormats = camera.supportedVideoFormats; console.log("supportedImageResolutions:" + supportedImageResolutions); console.log("supportedVideoResolutions:" + supportedVideoResolutions); console.log("supportedImageFormats:" + supportedImageFormats); console.log("supportedVideoFormats:" + supportedVideoFormats); }打印结果:supportedImageResolutions: 4160*3120,4000*3000,4160*2340,3840*2160.....supportedVideoResolutions: 4096*2160,3840*2160,1920*1080.....supportedImageFormats: jpgsupportedVideoFormats: mp4
拍照: var camera = plus.camera.getCamera( 1 ); //获取摄像头管理对象 camera.captureImage(function(capturedFile){ console.log("capturedFile:"+capturedFile); }, function(e){ console.log("拍照错误:"+e.message); },{ index:1, popover:{ top:'0px', left:'0px' } });打印结果:capturedFile: _doc/1497526342406.jpg
摄像: var camera = plus.camera.getCamera( 1 ); //获取摄像头管理对象 camera.startVideoCapture(function(capturedFile){ console.log("capturedFile:"+capturedFile); }, function(e){ console.log("摄像错误:"+e.message); },{ index:1, popover:{ top:'0px', left:'0px' } });打印结果: capturedFile: _doc/1497526787873.mp4
- H5移动端调用底层接口的一些使用方法-01调用系统的摄像头
- h5调用微信底层接口的一些知识
- H5调用摄像头
- H5调用本地摄像头
- H5 调用摄像头
- H5 调用摄像头
- 原生H5调用摄像头
- H5调用摄像头
- 2.3以前的系统调用前置摄像头
- android中调用系统封装的摄像头
- 调用系统的相册和摄像头问题
- GoLang之调用C接口的使用方法
- android 调用系统的接口
- android 调用系统的接口
- j2me 摄像头的调用
- android 摄像头的调用
- android 摄像头的调用
- 系统调用的一些函数
- 记票统计
- 串口波特率计算详解
- javascript 中的 this用法。
- vm安装mac虚拟机 vcpu-0错误
- 机器学习算法实现解析——libFM之libFM的训练过程之Adaptive Regularization
- H5移动端调用底层接口的一些使用方法-01调用系统的摄像头
- corsFilter java ajax解决认证(Authorization)跨域问题
- dijkstra模板
- 【Android Studio】 AS 使用记录04(自定义打包apk名)
- iOS开发中,各个UI控件之间的继承关系
- FlashBuilder精选插件
- 欢迎使用CSDN-markdown编辑器
- MySQL存储过程详解(终极版)
- request对象