-
Notifications
You must be signed in to change notification settings - Fork 1
event
Su, Jia edited this page Jan 3, 2018
·
2 revisions
回调接口
public interface KMCAgoraEventListener {
//加入频道结果
int JOIN_CHANNEL_RESULT = 1;
//收到remote端第一帧视频数据
int FIRST_FRAME_DECODED = 2;
int ON_VENDOR_MSG = 3;
//有用户加入
int USER_JOINED = 4;
//错误
int ERROR = 5;
//离开频道的回调
int LEAVE_CHANNEL = 6;
//用户退出连麦
int USER_OFFLINE = 7;
void onEvent(int event, Object... data);
}
状态回调函数需在KMCAgoraVRTC类的registerEventListener中注册,
demo中示例在KMCAgoraStreamer类中,
mStreamer.registerAgoraEventListener(new KMCAgoraEventListener() {
@Override
public void onEvent(int event, Object... data) {
switch (event) {
case KMCAgoraEventListener.USER_JOINED: {
int uid = (int) data[0];
Log.d(TAG, "用户 " + uid + " 加入频道");
break;
}
case KMCAgoraEventListener.JOIN_CHANNEL_RESULT: {
boolean success = (Boolean) data[0];
if (success) {
Log.d(TAG, "加入频道成功");
makeToast("加入频道成功");
}
break;
}
case KMCAgoraEventListener.FIRST_FRAME_DECODED: {
break;
}
case KMCAgoraEventListener.LEAVE_CHANNEL: {
Log.d(TAG, "退出频道");
break;
}
case KMCAgoraEventListener.USER_OFFLINE: {
int uid = (int) data[0];
Log.d(TAG, "用户 " + uid + " 离开频道");
break;
}
case KMCAgoraEventListener.ERROR: {
int errorCode = (Integer) data[0];
switch (errorCode) {
case AgoraErrorCode.ERR_INVALID_APP_ID:
makeToast("错误的app id");
stopRTC();
break;
case AgoraErrorCode.ERR_GET_VALID_CHANNEL_KEY:
makeToast("获取channel key失败");
stopRTC();
break;
case AgoraErrorCode.ERR_INVALID_ARGUMENT:
Log.d(TAG, "调用api参数错误");
stopRTC();
break;
case AgoraErrorCode.ERR_NOT_READY:
makeToast("未初始化完成");
stopRTC();
break;
case AgoraErrorCode.ERR_REFUSED:
makeToast("不能发起通话,可能是处于另外一个通话中未退出,或者创建频道失败");
stopRTC();
break;
default:
Log.d(TAG, "错误码 " + errorCode);
}
}
}
}
});