自学内容网 自学内容网

Android 音频通道切换HDMI,蓝牙,喇叭

Android 音频通道切换HDMI,蓝牙,喇叭

private void speakerSound() {
        if (soundOutput.equals("speaker")) {
            return;
        }
        soundOutput = "speaker";
        audoManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
        audoManager.setMode(AudioManager.STREAM_MUSIC);
        audoManager.stopBluetoothSco();
        audoManager.setBluetoothScoOn(false);
        audoManager.setSpeakerphoneOn(true);
    }

    private void hdmiSound() {
        if (soundOutput.equals("hdmi")) {
            return;
        }
        soundOutput = "hdmi";
mContext.getSystemService(Context.AUDIO_SERVICE);
        audoManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
        audoManager.stopBluetoothSco();
        audoManager.setBluetoothScoOn(true);
        audoManager.setSpeakerphoneOn(false);
    }

    private void bluetoothSound() {
        if (soundOutput.equals("bluetooth")) {
            return;
        }
        soundOutput = "bluetooth";
        audoManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
        audoManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
        audoManager.startBluetoothSco();
        audoManager.setBluetoothScoOn(true);
        audoManager.setSpeakerphoneOn(false);
    }

参考:
https://blog.csdn.net/u010983881/article/details/72420790


原文地址:https://blog.csdn.net/qq_31939617/article/details/140470526

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!