本文介绍了与 SDK 工具相关的 API。
获取版本号
IdrsSdk.Version
请求参数
无
返回值
类型 | 说明 |
String | 版本号 |
代码示例
IdrsSdk.Version
结果上报
public static void uploadFiles(final IdrsProcessResultBean resultBean, UploadCallback callback)
请求参数
参数 | 类型 | 说明 | 是否必须 |
resultBean | IdrsProcessResultBean | 上报结果数据 | 是 |
callback | UploadCallback | 上报结果回调 | 是 |
IdrsProcessResultBean 说明
参数 | 类型 | 说明 | 是否必须 |
files | List<FileBean> | 文件数组 | 是 |
appId | String | 应用 ID | 是 |
ak | String | AK | 是 |
sk | String | SK | 是 |
detectProcessId | String | 流程 ID | 是 |
roomId | String | 房间号 | 是 |
recordAt | String | 开始录制时间 | 是 |
duration | long | 录制长度,单位为秒(s) | 是 |
rtcRecordId | long | RTC 录制 ID | 是 |
outerBusinessId | String | 自定义业务参数 | 是 |
type | String |
| 是 |
回调
方法 | 说明 |
void success(String json); | 成功回调 |
void fail(String msg); | 失败回调 |
代码示例
long recordDuration = System.currentTimeMillis() - recordAtLong;
UploadReportRequest reportRequest = new UploadReportRequest();
reportRequest.setAppId(appId);
reportRequest.setRoomId(mRoomInfo.roomId);
reportRequest.setType(IdrsSdk.TYPE_REMOTE);
reportRequest.setRecordAt(recordAt);
reportRequest.setDuration(recordDuration/1000);
String metaFileName = "remotemeta";
GetAppBean.DataBean data = IdrsSdk.getInstance().getAppData();
String metaFilePath = ConfigurationFile.getInstance().createMetaFilePath(CreateRoomActivity.this, metaFileName);
VideoConfigurator.getInstance().saveToFile(metaFilePath);
String resultFilename = "remoteresult";
String resultFilePaht = ConfigurationFile.getInstance().createMetaFilePath(CreateRoomActivity.this, resultFilename);
VideoConfigurator.getInstance().saveResultToFile(resultFilePaht);
IdrsProcessResultBean idrsResultBean = new IdrsProcessResultBean();
idrsResultBean.setAk(AK);
idrsResultBean.setSk(SK);
idrsResultBean.setAppId(appId);
idrsResultBean.setFeeId(data == null ? "" : data.getFeeId());
idrsResultBean.setType(IdrsSdk.TYPE_REMOTE);
idrsResultBean.setRoomId(mRoomInfo.roomId);
idrsResultBean.setDuration(recordDuration);
idrsResultBean.setRecordAt(recordAtLong);
idrsResultBean.setRecordId(recordId);
idrsResultBean.setOuterBusinessId(outerBusinessId);
List<FileBean> fileBeanList = new ArrayList<>();
idrsResultBean.setFiles(fileBeanList);
FileBean metaBean = new FileBean();
metaBean.setFileName(metaFileName);
metaBean.setUrlType(IdrsProcessResultBean.FILE_TYPE_META);
metaBean.setFilePath(metaFilePath);
fileBeanList.add(metaBean);
FileBean resultBean = new FileBean();
resultBean.setFileName(resultFilename);
resultBean.setUrlType(IdrsProcessResultBean.FILE_TYPE_RESULT);
resultBean.setFilePath(resultFilePaht);
fileBeanList.add(resultBean);
IdrsSdk.uploadFiles(idrsResultBean, new UploadCallback() {
@Override
public void success(String json) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(CreateRoomActivity.this, "上报成功", Toast.LENGTH_LONG).show();
}
});
}
@Override
public void fail(final String msg) {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(CreateRoomActivity.this, "上报失败:"+msg, Toast.LENGTH_LONG).show();
}
});
}
});
SDK 销毁
public void release()
请求参数
无
返回值
无
代码示例
IdrsSdk.getInstance().release();
动态加载资源包
动态获取资源文件设置
implementation platform("com.mpaas.android:$mpaas_artifact:$mpaas_baseline")
implementation ('com.mpaas.android:idrs') {
exclude module:'idrs-dynamic-res-local-pkg-build' //云端资源本地包模块
}
下载资源文件
public void getSdkResource(Context context, IdrsParams idrsParams, SdkResourceCallback resourceCallBack)
请求参数
参数 | 类型 | 说明 | 是否必须 |
context | Context | 上下文 | 是 |
idrsParams | IdrsParams | 初始化参数 | 是 |
resourceCallBack | SdkResourceCallback | 下载文件回调接口 | 是 |
代码示例
IdrsParams idrsParams = new IdrsParams();
idrsParams.sUid = userId;
idrsParams.sAppId = appId;
idrsParams.AK = ak;
idrsParams.SK = sk;
idrsParams.sType = type;
idrsParams.sSecurityToken = token;
idrsParams.engineTypes = EnumSet.of(
EngineType.AUDIO_DETECT_ENGINE,
EngineType.FACE_DETECT_ENGINE,
EngineType.HAND_DETECT_ENGINE,
EngineType.OCR_DETECT_ENGINE,
EngineType.LOCAL_RECORDE_ENGINE);
IdrsSdk.getInstance().getSdkResource(MainActivity.this, idrsParams, new SdkResourceCallback() {
@Override
public void success() {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (downloadDialog!=null){
downloadDialog.dismiss();
}
Toast.makeText(MainActivity.this, "资源文件加载成功", Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void fail(String s) {
}
@Override
public void progress(final int progress) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (downloadDialog==null){
showDownloadDialog();
}
if (downloadDialog!=null){
downloadDialog.setTvDownloadProgress(progress);
}
}
});
}
});
文档内容是否对您有帮助?