Sinch Camera Local view is not opening camera showing only black screen when i try to video call from Sinch library

Viewed 53

I Am working on a video call type app , and for video call I am using Sinch Library for video call But when in initializing the call my camera is not opening ,its showing only black screen on my view , i have give all permissions also Ask runtime permission for camera but still its showing me only black screen

Here is my code to Place the call using Sinch Service

      if (permissionsAvailable(permissionsSinch)) {
        try {
            Call call = callIsVideo ? getSinchServiceInterface().callUserVideo(user.getId()) : getSinchServiceInterface().callUser(user.getId());


            if (call == null) {
                // Service failed for some reason, show a Toast and abort
                Toast.makeText(this, "Service is not started. Try stopping the service and starting it again before placing a call.", Toast.LENGTH_LONG).show();
                return;
            }
            String callId = call.getCallId();
            startActivity(CallScreenActivity.newIntent(this, user, callId, "OUT"));
        } catch (Exception e) {
            Log.e("CHECK", e.getMessage());
            //ActivityCompat.requestPermissions(this, new String[]{e.getRequiredPermission()}, 0);
        }
    } else {
        ActivityCompat.requestPermissions(this, permissionsSinch, 69);
    }

This is the code to showing the Local view on My releative layout ID

  if (getSinchServiceInterface() == null) {
        return; // early
    }

    Call call = getSinchServiceInterface().getCall(mCallId);
    if (call != null) {
        mCallerName.setText(user != null ? user.getNameToDisplay() : call.getRemoteUserId());
        mCallState.setText(call.getState().toString());
        isVideo = call.getDetails().isVideoOffered();



        if (isVideo) {
            addLocalView();
            if (call.getState() == CallState.ESTABLISHED) {
                addRemoteView();
            }
            mySwitchCameraLLY.setVisibility(View.VISIBLE);
        } else {
            mySwitchCameraLLY.setVisibility(View.GONE);
        }

        myTxtCalling.setText(getResources().getString(R.string.app_name) + (isVideo ? " Video Calling" : " Voice Calling"));
        tintBlue.setVisibility(isVideo ? View.GONE : View.VISIBLE);
        localVideo.setVisibility(!isVideo ? View.GONE : View.VISIBLE);
    }

AddLocalView Method Code

     if (mLocalVideoViewAdded || getSinchServiceInterface() == null) {
        return; //early
    }
    final VideoController vc = getSinchServiceInterface().getVideoController();
    if (vc != null) {
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, 50);
        }    else {
            runOnUiThread(() -> {
                ViewGroup localView = getVideoView(true);
                localView.addView(vc.getLocalView());
                localView.setOnClickListener(v -> vc.toggleCaptureDevicePosition());
                mLocalVideoViewAdded = true;
                vc.setLocalVideoZOrder(!mToggleVideoViewPositions);
                localVideo.setOnTouchListener(new OnDragTouchListener(localVideo, remoteVideo));
       /*     switchVideo.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    vc.toggleCaptureDevicePosition();
                }
            });*/
            });
        }

    }
0 Answers
Related