功能描述
通过js接口录制音频
支持格式
Json
请求参数:
字段 |
可选 |
类型及范围 |
说明 |
duration |
否 |
int |
音频录制的最长时间,以秒为单位 |
请求调用示例
params={ "duration":60 }; LightSDK.native.startRecord(params,cb);
|
返回值说明
字段名 |
字段类型 |
说明 |
result |
string |
录制音频文件的base64编码 |
返回字段示例
"data": {"result":"iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAIAAAD2HxkiAAAF0UlEQVR4nO3dQY7jOBAAwfZi///l2cPeOQCFUpLuiOtg7LbshA4qFD9//vz5ATr/1H8A/HYihJgIISZCiIkQYiKEmAghJkKI/bv4t8/n89rfMW09k7D4pEPDDOtru/2myVeWXKK7rC+ROyHERAgxEUJMhBATIcRECDERQkyEEBMhxFYTM2un7cUYGrAYetknV++0+Z6h6Z+1b/r5uRNCTIQQEyHERAgxEUJMhBATIcRECDERQmx/YmbtwEGT91922/bVO3Avy2nzPdvmfiTuhBATIcRECDERQkyEEBMhxEQIMRFCbOph/V1Oe6D8S46v4X/uhBATIcRECDERQkyEEBMhxEQIMRFCTIQQMzEz6MBlE+97f77nOu6EEBMhxEQIMRFCTIQQEyHERAgxEUJMhBCbmpj5mmGIJ+tVvub4mu2dN3/9vxOu++25E0JMhBATIcRECDERQkyEEBMhxEQIsf2H9b9kd8PQc+rkQJi7/tq1b/r5uRNCTIQQEyHERAgxEUJMhBATIcRECDERQuxz3S6Alw0Ni/Bz4R6KIe6EEBMhxEQIMRFCTIQQEyHERAgxEUJMhBCbOhBmYej8kKGXvWuqI9naklyioWmk7UU72y/7404IORFCTIQQEyHERAgxEUJMhBATIcSmHta/fwzIgY+Mh578LgxNLAy96fsP3P9q6LCdNXdCiIkQYiKEmAghJkKIiRBiIoSYCCEmQoitJmaejF+8v6XirpNbkr9naIFFcu7NXT+wNXdCiIkQYiKEmAghJkKIiRBiIoSYCCEmQoh97jrw5P3VNQdKDi1ZSE742TY0/WNiBi4mQoiJEGIihJgIISZCiIkQYiKE2P6BMMkj2vdPF1lL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EGIihJgIISZCiIkQYiKEmAghJkKI/QfOdxtqmV9A+gAAAABJRU5ErkJggg=="}
|
注意事项
1.需要在config.js配置文件中做以下配置:
module.exports = { plugins:{ "audio": {} //老版本的media不再提供维护 } };
|
callback将在duration时长结束后执行,或在用户调用media.audio.stopRecord后执行。