Android Quickblox视频通话扬声器不会自动打开

时间:2019-05-17 08:01:06

标签: android quickblox quickblox-android

我已经在Android,iOS和Web中实现了quickblox用于视频通话。但是在android中,当我们收到视频通话时,我面临一个问题,那么电话的扬声器不会自动打开。我想在接到视频通话时自动打开扬声器。

我的音频管理器示例代码:-

position

当我尝试通过添加以下行来控制音频流管理器时,我的应用程序崩溃了

audioManager = AppRTCAudioManager.create(this);

    isVideoCall = QBRTCTypes.QBConferenceType.QB_CONFERENCE_TYPE_VIDEO.equals(currentSession.getConferenceType());
    if (isVideoCall) {

        audioManager.setDefaultAudioDevice(AppRTCAudioManager.AudioDevice.SPEAKER_PHONE);


        Log.d(TAG, "AppRTCAudioManager.AudioDevice.SPEAKER_PHONE");
    } else {
        audioManager.setDefaultAudioDevice(AppRTCAudioManager.AudioDevice.EARPIECE);
        audioManager.setManageSpeakerPhoneByProximity(SettingsUtil.isManageSpeakerPhoneByProximity(this));
        Log.d(TAG, "AppRTCAudioManager.AudioDevice.EARPIECE");
    }

    audioManager.setOnWiredHeadsetStateListener((plugged, hasMicrophone) -> {
        if (callStarted) {
            Toaster.shortToast("Headset " + (plugged ? "plugged" : "unplugged"));
        }
    });

    audioManager.setBluetoothAudioDeviceStateListener(connected -> {
        if (callStarted) {
            Toaster.shortToast("Bluetooth " + (connected ? "connected" : "disconnected"));
        }
    }); 

崩溃报告:

   QBRTCAudioTrack localAudioTrack = currentSession.getMediaStreamManager().getLocalAudioTrack();
    localAudioTrack.setEnabled(true); // enable or disable audio stream

1 个答案:

答案 0 :(得分:0)

尝试下面的代码

private AppRTCAudioManager audioManager;

audioManager = AppRTCAudioManager.create(this, new AppRTCAudioManager.OnAudioManagerStateListener() {
        @Override
        public void onAudioChangedState(AppRTCAudioManager.AudioDevice audioDevice) {

        }
    });

audioManager.setDefaultAudioDevice(AppRTCAudioManager.AudioDevice.SPEAKER_PHONE);