/** 接听呼叫 */ private void answerCall() { try { EMChatManager.getInstance().answerCall(); cameraHelper.setStartFlag(true); isGoing = true; openSpeakerOn(); LogUtil.e("xmh-record", "answer call", true); } catch (Exception e) { e.printStackTrace(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_watch); ButterKnife.bind(this); getWindow() .addFlags( WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON // 保持屏幕常亮 | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD // 关闭键盘 ); // 退出登录并使用username_uuid登录,记着拼接下划线(LoginUtil.USERNAME_EYE_DEPART) LoginUtil.relogin( AppConfig.getUsername() + LoginUtil.USERNAME_EYE_DEPART + CommonUtil.getUUID(this), new EMCallBack() { @Override public void onSuccess() { LogUtil.e("xmh-login", "eye"); initAfterLogin(); } @Override public void onError(int i, String s) { // do nothing } @Override public void onProgress(int i, String s) { // do nothing } }); callHelper = EMVideoCallHelper.getInstance(); LogUtil.e("xmh-record", "helper-create"); cameraHelper = new CameraHelper(this, callHelper, surface.getHolder()); callHelper.setSurfaceView(null); surface.getHolder().addCallback(new LocalCallback()); // 设置视频状态监听 setCallStateListener(); setConnectionListener(); audioManager = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE); audioManager.setMode(AudioManager.MODE_RINGTONE); audioManager.setSpeakerphoneOn(true); // 监听结束通话广播 LocalBroadcastManager.getInstance(this) .registerReceiver( new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (isGoing) { // 结束通话 EMChatManager.getInstance().endCall(); cameraHelper.setStartFlag(false); isGoing = false; LogUtil.e("xmh-record", "end call", true); } } }, new IntentFilter(CommendUtil.ACTION_END_CALL)); }
@Override public void surfaceDestroyed(SurfaceHolder holder) { LogUtil.e("xmh-record", "surface-destory"); }
@Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { LogUtil.e("xmh-record", "surface-change"); cameraHelper.startCapture(); }
@Override public void surfaceCreated(SurfaceHolder holder) { LogUtil.e("xmh-record", "surface-created"); }