从 sinch 视频通话中分离麦克风

Detach microphone from sinch video call

当用户使用 sinch 视频通话时,我需要麦克风来记录他说的话然后翻译。但我不能使用麦克风。 有人可以帮助我吗?

麦克风一次只能由一个进程使用。您可以使用下面的片段检查 Sinch 视频通话是否占用了麦克风

public static boolean checkIfMicrophoneIsBusy(Context ctx){
    AudioRecord audio = null;
    boolean ready = true;
    try{
        int baseSampleRate = 44100;
        int channel = AudioFormat.CHANNEL_IN_MONO;
        int format = AudioFormat.ENCODING_PCM_16BIT;
        int buffSize = AudioRecord.getMinBufferSize(baseSampleRate, channel, format );
        audio = new AudioRecord(MediaRecorder.AudioSource.MIC, baseSampleRate, channel, format, buffSize );
        audio.startRecording();
        short buffer[] = new short[buffSize];
        int audioStatus = audio.read(buffer, 0, buffSize);

        if(audioStatus == AudioRecord.ERROR_INVALID_OPERATION || audioStatus == AudioRecord.STATE_UNINITIALIZED /* For Android 6.0 */)
            ready = false;
    }
    catch(Exception e){
        ready = false;
    }
    finally {
        try{
            audio.release();
        }
        catch(Exception e){}
    }

    return ready;
}