-
Notifications
You must be signed in to change notification settings - Fork 53
compose_stat_callback
zanxiaofei edited this page Jan 3, 2018
·
7 revisions
KSYEditKit类中提供以下两种回调接口
- OnInfoListener 包含编辑和合成过程中状态变更事件回调,状态码为正数
- OnErrorListener 包含编辑和合成过程中错误事件回调,状态码为负数
名称 | 数值 | 含义 | msgs |
---|---|---|---|
SHORTVIDEO_COMPOSE_START | 1 | 合成开始 | N/A |
SHORTVIDEO_COMPOSE_FINISHED | 2 | 合成结束 | msg[0] 合成后文件路径,一般为合成时传入的文件路径 |
SHORTVIDEO_COMPOSE_ABORTED | 3 | 合成中止 | 由用户触发中止后,中止结束后的回调 |
mEditKit.setOnInfoListener(mOnInfoListener);//设置合成状态回调
private KSYEditKit.OnInfoListener mOnInfoListener = new KSYEditKit.OnInfoListener() {
@Override
public Object onInfo(int type, String... msgs) {
Log.e(TAG, "on info:" + type);
switch (type) {
case ShortVideoConstants.SHORTVIDEO_COMPOSE_START: {
//合成开始
mEditKit.pauseEditPreview();
if (mComposeDialog != null && mComposeDialog.isShowing()) {
mComposeDialog.composeStarted();
}
return null;
}
case ShortVideoConstants.SHORTVIDEO_COMPOSE_FINISHED: {
//合成结束
clearImgFilter();
Log.e(TAG, "compose finished");
if (mComposeDialog != null && mComposeDialog.isShowing()) {
mComposeDialog.composeFinished(msgs[0]);
}
mComposeFinished = true;
// 可在此处触发sdk将合成后文件上传到ks3,示例代码如下:
// //上传必要信息:bucket,objectkey,及PutObjectResponseHandler上传过程回调
// String mineType = FileUtils.getMimeType(new File(msgs[0]));
// StringBuilder objectKey = new StringBuilder(getPackageName() +
// "/" + System.currentTimeMillis());
// if (mineType == FileUtils.MIME_TYPE_MP4) {
// objectKey.append(".mp4");
// } else if (mineType == FileUtils.MIME_TYPE_GIF) {
// objectKey.append(".gif");
// }
// mCurObjectKey = objectKey.toString();
// KS3ClientWrap.KS3UploadInfo bucketInfo = new KS3ClientWrap.KS3UploadInfo
// ("ksvsdemo", mCurObjectKey, mPutObjectResponseHandler);
// return bucketInfo;
return null;
}
default:
return null;
}
return null;
}
};
名称 | 数值 | 含义 | msgs |
---|---|---|---|
SHORTVIDEO_ERROR_SDK_AUTHFAILED | -1 | SDK鉴权失败,无法合成 | N/A |
SHORTVIDEO_ERROR_COMPOSE_FAILED_UNKNOWN | -4000 | 文件合成未知错误 | N/A |
SHORTVIDEO_ERROR_COMPOSE_FILE_OPEN_FAILED | -4001 | 文件合成生成文件失败 | N/A |
SHORTVIDEO_ERROR_COMPOSE_FILE_WRITE_FAILED | -4002 | 文件合成写文件失败 | N/A |
SHORTVIDEO_ERROR_COMPOSE_FILE_CLOSE_FAILED | -4003 | 文件合成文件关闭失败 | N/A |
SHORTVIDEO_ERROR_COMPOSE_FILE_FORMAT_NOT_SUPPORTED | -4004 | 文件合成,文件格式不支持 | N/A |
SHORTVIDEO_ERROR_COMPOSE_FILE_TITLE_OR_TAIL_FAILED | -4005 | 片头片尾添加失败 | 具体失败信息 |
示例代码
mEditKit.setOnErrorListener(mOnErrorListener);
private KSYEditKit.OnErrorListener mOnErrorListener = new KSYEditKit.OnErrorListener() {
@Override
public void onError(int type, long msg) {
switch (type) {
case ShortVideoConstants.SHORTVIDEO_ERROR_COMPOSE_FAILED_UNKNOWN:
case ShortVideoConstants.SHORTVIDEO_ERROR_COMPOSE_FILE_CLOSE_FAILED:
case ShortVideoConstants.SHORTVIDEO_ERROR_COMPOSE_FILE_FORMAT_NOT_SUPPORTED:
case ShortVideoConstants.SHORTVIDEO_ERROR_COMPOSE_FILE_OPEN_FAILED:
case ShortVideoConstants.SHORTVIDEO_ERROR_COMPOSE_FILE_WRITE_FAILED:
Log.d(TAG, "compose failed:" + type);
Toast.makeText(EditActivity.this,
"Compose Failed:" + type, Toast.LENGTH_LONG).show();
if (mComposeDialog != null && mComposeDialog.isShowing()) {
mComposeDialog.closeDialog();
resumeEditPreview();
}
break;
case ShortVideoConstants.SHORTVIDEO_ERROR_SDK_AUTHFAILED:
Log.d(TAG, "sdk auth failed:" + type);
Toast.makeText(EditActivity.this,
"Auth failed can't start compose:" + type, Toast.LENGTH_LONG).show();
if (mComposeDialog != null) {
mComposeDialog.closeDialog();
resumeEditPreview();
}
break;
// case ShortVideoConstants.SHORTVIDEO_ERROR_UPLOAD_KS3_TOKEN_ERROR:
// Log.d(TAG, "ks3 upload token error, upload to ks3 failed");
// Toast.makeText(EditActivity.this,
// "Auth failed can't start upload:" + type, Toast.LENGTH_LONG).show();
// break;
default:
Log.d(TAG, "KSYEditKit error:" + type + "_" + msg);
break;
}
}
};