|
private int roomId;
private int interviewId;
private SurfaceView surfaceLarge,surfaceSmall;
private AnyChatCoreSDK anyChat = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
roomId = getIntent().getIntExtra(MFHRConstant.ROOM_ID, -1);
interviewId = getIntent().getIntExtra(MFHRConstant.INTERVIEW_ID, -1);
anyChat = MFHRApplication.getInstance().getAnyChatService();
surfaceLarge = (SurfaceView)findViewById(R.id.surface_large);
surfaceSmall = (SurfaceView)findViewById(R.id.surface_small);
anyChat.SetBaseEvent(this);
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_LOCALVIDEO_AUTOROTATION, 1);
AnyChatCoreSDK.SetSDKOptionInt(AnyChatDefine.BRAC_SO_LOCALVIDEO_OVERLAY, 1);
anyChat.mSensorHelper.InitSensor(this);
AnyChatCoreSDK.mCameraHelper.SetContext(this);
AnyChatCoreSDK.mCameraHelper.SelectVideoCapture(0);
surfaceSmall.getHolder().addCallback(AnyChatCoreSDK.mCameraHelper);
anyChat.Connect("192.168.0.215", 8906);
// findViewById(R.id.btn_roate_camera).setOnClickListener(new View.OnClickListener() {
//
// @Override
// public void onClick(View v) {
// AnyChatCoreSDK.mCameraHelper.SwitchCamera();
// }
// });
}
@Override
public void OnAnyChatObjectEvent(int dwObjectType, int dwObjectId, int dwEventType, int dwParam1, int dwParam2,
int dwParam3, int dwParam4, String strParam) {
}
@Override
public void OnAnyChatConnectMessage(boolean bSuccess) {
if(bSuccess){
Toast.makeText(VideoHrActivity.this, "链接服务器成功", Toast.LENGTH_SHORT).show();
anyChat.Login("test","");
}else{
Toast.makeText(VideoHrActivity.this, "链接服务器失败", Toast.LENGTH_SHORT).show();
}
}
@Override
public void OnAnyChatLoginMessage(int dwUserId, int dwErrorCode) {
if(dwErrorCode == 0){
Toast.makeText(VideoHrActivity.this, "登录成功", Toast.LENGTH_SHORT).show();
anyChat.EnterRoom(roomId, "");
}else{
Toast.makeText(VideoHrActivity.this, "登录失败", Toast.LENGTH_SHORT).show();
}
}
@Override
public void OnAnyChatEnterRoomMessage(int dwRoomId, int dwErrorCode) {
if(dwErrorCode == 0){
Toast.makeText(VideoHrActivity.this, "进入房间成功", Toast.LENGTH_SHORT).show();
anyChat.UserCameraControl(-1, 1);
anyChat.UserSpeakControl(-1, 1);
}else{
Toast.makeText(VideoHrActivity.this, "进入房间失败", Toast.LENGTH_SHORT).show();
}
}
@Override
public void OnAnyChatOnlineUserMessage(int dwUserNum, int dwRoomId) {
}
@Override
public void OnAnyChatUserAtRoomMessage(int dwUserId, boolean bEnter) {
if(bEnter){
userID = dwUserId;
Toast.makeText(VideoHrActivity.this, "有人进入", Toast.LENGTH_SHORT).show();
int index = anyChat.mVideoHelper.bindVideo(surfaceLarge.getHolder());
anyChat.mVideoHelper.SetVideoUser(index, dwUserId);
anyChat.UserCameraControl(dwUserId, 1);
anyChat.UserSpeakControl(dwUserId, 1);
}else{
userID = 0;
Toast.makeText(VideoHrActivity.this, "有人离开", Toast.LENGTH_SHORT).show();
anyChat.UserCameraControl(dwUserId, 0);
anyChat.UserSpeakControl(dwUserId, 0);
}
}
@Override
public void OnAnyChatLinkCloseMessage(int dwErrorCode) {
} |
|