拍视频

调用系统相机机进行录像

[!TIP|labelVisibility:hidden|iconVisibility:hidden] navigator.camera.shootVideo(captureSuccess,captureError,saveToAlbum)

支持平台:

  • Android
  • iOS

参数说明

参数 类型 必填 说明
captureSuccess Function 录像结果回调函数
captureError Function 录像错误回调函数
saveToAlbum Boolean 视频是否保存, true保存到相册,false保存到沙盒,默认保存到沙盒

captureSuccess返回拍照结果的一个对象,其属性包含以下一项或多项:

  • fullPath(String) -- 视频全路径(含file:///)
  • lastModifiedDate(Number) -- 视频最后被修改的时间,单位毫秒
  • localURL(String) -- 视频本地URL(遵守cdvfile协议)
  • name(String) -- 视频名称
  • size(Number) -- 视频大小,单位 bytes
  • thumbLocalURL(String) -- 视频缩略图本地URL(遵守cdvfile协议)
  • type(String) -- 文件mine type类型

captureError返回一个对象,其属性包含以下一项或多项:

  • code(Int) -- 错误码,表示错误结果

示例代码

// 引用js
<script src='supconit://hcmobile.js'></script>
<script>
    // 监听’deviceready‘事件
    document.addEventListener('deviceready', onDeviceReady, false)
    function onDeviceReady(){
        navigator.camera.shootVideo(function (successCallback) {
          alert(JSON.stringify(successCallback));
        },function (errorCallback){
          alert(JSON.stringify(errorCallback));
        },true);
    }
</script>

响应示例代码:

{
    "fullPath":"assets-library://asset/asset.MOV?id=BDFEE02C-9B84-4625-910D-A3536792046D&ext=MOV",
    "thumbLocalURL":"cdvfile://localhost/root/private/var/mobile/Containers/Data/Application/E7760340-0530-4184-A0CB-091CE5F48407/tmp/IMG_0442_thumb.jpeg",
    "lastModifiedDate":1584339272000,
    "size":361764,
    "localURL":"cdvfile://localhost/assets-library/asset/asset.MOV?id=BDFEE02C-9B84-4625-910D-A3536792046D&ext=MOV",
    "type":"video/quicktime",
    "name":"IMG_0442.MOV"
}

results matching ""

    No results matching ""