cameracontext.stoprecord(object object)
基础库 或更高版本; 若版本较低,建议采取 兼容处理 。
支小宝客户端 支持
安诊儿客户端 支持
小程序开发者工具: 不支持。请以真机的调试结果为准。
主体: 企业支付宝小程序 、 个人支付宝小程序
结束录像。
object object
查看示例
属性 | 类型 | 默认值 | 必填 | 描述 |
---|---|---|---|---|
success | function | - | 否 | 调用成功的回调函数 |
fail | function | - | 否 | 调用失败的回调函数 |
complete | function | - | 否 | 调用结束的回调函数(调用成功、失败都会执行) |
success 回调函数
参数
object res
属性 | 类型 | 兼容性 | 描述 |
---|---|---|---|
tempthumbpath | string | - | 封面图片文件地址(本地临时文件) |
tempvideopath | string | - | 视频文件地址(本地临时文件) |
height | number | 基础库: 2.8.0 支付宝: 10.2.90 |
视频文件的高度,单位:px |
width | number | 基础库: 2.8.0 支付宝: 10.2.90 |
视频文件的宽度,单位:px |
size | number | 基础库: 2.8.0 支付宝: 10.2.90 |
视频文件的尺寸,单位:bytes |
duration | number | 基础库: 2.8.0 支付宝: 10.2.90 |
录制的持续时间,安卓时间单位为毫秒,ios 时间单位为秒 |
cameracontext.stoprecord(object, object)
success 回调参数
检测文件真实类型
.axml
.js
<camera
id="camera"
device-position="front"
flash="off"
style="width: 100%; height: 300px;"
onready="oncameraready"
/>
page ({
oncameraready (e) {
console.log ('相机初始化完成');
this.cameracontext = my.createcameracontext ('camera');
this.cameracontext.startrecord ({
timeoutcallback (res) {
console.log ('超时结束录制', res);
},
success: function (res) {
console.log (res);
},
fail: function (err) {
console.log (err);
},
});
// 20秒后结束录制
settimeout (() => {
this.cameracontext.stoprecord ({
success: function (res) {
console.log (res);
},
fail: function (err) {
console.log (err);
},
});
}, 20000);
},
});
{
"tempthumbpath": "https://resource/719e329e2d8cedb2f9aad42b11da23ec3.image",
"tempvideopath": "https://resource/d2ea29ad59d1550166ac5d7216e0b3c1ii10926c457a1f65d921db2adeeb275ea12.video",
"duration": 9.84000015258789,
"size": 1907337,
"height": 720,
"width": 944,
"success": "true"
}
this.cameracontext.stoprecord ({
success: function (res) {
console.log (res);
// 以查视频真实文件扩展名为例
my.detectfiletype ({
filepath: res.tempvideopath,
success (res) {
console.log ('detectfiletype: success', res);
},
fail (err) {
console.log ('detectfiletype: fail', err);
},
});
},
fail: function (err) {
console.log (err);
},
});
-
tip
封面图片地址、视频文件地址文件扩展名并非为文件真实类型,在真机上扩展名是 .image、.video。
若需判断文件实际扩展名,可使用 my.detectfiletype 进行查询,请以此接口返回结果为准,不过需注意此接口仅限真机调试,可参考上方 示例代码。