在我的应用程序中,我正在实现视频聊天,为此我正在使用sinch客户端,我正在下面提供官方文档提供的链接。
https://www.sinch.com/docs/video/android/#videocalling
并使用下面的代码我将远程视图添加到布局
@Override
public void onVideoTrackAdded(Call call) {
Log.e("test","video track added is called now");
SinchClient sinchClient = getSinchServiceInterface().getSinchClient();
if (sinchClient != null) {
VideoController videoController = sinchClient.getVideoController();
View myPreview = videoController.getLocalView();
View remoteView = videoController.getRemoteView();
mUpperLinearLayout.addView(myPreview);
mLowerLinearLayout.addView(remoteView);
}
}
我已将我的UI拆分为两个线性布局名称上部布局和下部布局,我将远程视图添加到文档中提到的线性布局。但是我在成功连接视频通话时会看到黑色或空白视图。为什么我错过了什么?我在log cat中观察到的另一件事就是如下所述出现错误
CameraEnumerator: java.lang.RuntimeException: Fail to connect to camera service
我搜索了很多内容并尝试了不同的链接,如下所述
Sinch Video Chat - Remote Video Issue
但没有运气。有什么帮助吗?
我使用下面的代码进行许可。
private void callVideo() {
try {
Call call = getSinchServiceInterface().callVideoUser(mVoipContact.getUserName());
if (call == null) {
// Service failed for some reason, show a Toast and abort
Toast.makeText(getApplicationContext(), getString(R.string.txt_service_not_started) + getString(R.string.txt_placing_call), Toast.LENGTH_LONG).show();
return;
}
String callId = call.getCallId();
Intent callScreen = new Intent(getApplicationContext(), VideoCallScreenActivity.class);
callScreen.putExtra(VoipConstants.CALL_ID, callId);
startActivity(callScreen);
} catch (MissingPermissionException e) {
ActivityCompat.requestPermissions(MessagingActivity.this, new String[]{e.getRequiredPermission()}, REQUEST_CODE_PERMISSION_CALL);
}
}
现在我可以看到下面的log cat错误
VideoCapturerAndroid: Camera freezed: Camera failure.
答案 0 :(得分:0)
Like this
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, 50);
} else {
callVideo();
}
For other error try adding this setPreviewTexture()
in Try Catch OR just remove this line
答案 1 :(得分:0)
当远程视图处于活动状态时,您正在添加localView。在sinch客户端准备好时尝试添加localView。在sinch中,如果localView不清楚,则远程视图将不会显示。
我不知道你的代码流,所以我不知道你必须在哪里添加localView。
我希望,它会对你有帮助。