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

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

bash 复制代码
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

相关推荐
limuyang214 小时前
PDF Viewer KMP(基于 chrome 的 PDFium 内核)
android·kotlin
心平气和量大福大18 小时前
android-控件-搜索框SearchView
android·gitee
2601_9621771318 小时前
【MySQL篇】聚合查询,联合查询
android·java·mysql
壮哥_icon18 小时前
【Android】批量 VectorDrawable 动态分别修改 fillColor 和 strokeColor 的踩坑与终极解决方案
android
齐天qaq20 小时前
Android 系统 APK 分区与权限
android
心平气和量大福大20 小时前
android-控件-多选框CheckBox
android·gitee
pengyu21 小时前
【Kotlin 协程修仙录 · 大乘境 · 初阶】 | 跳出三界:协程在 KMP 与后端开发中的跨平台之道
android·kotlin
XiaoLeisj21 小时前
Android Memory Profiler:堆内存指标、内存抖动与泄漏定位
android·性能优化·内存抖动·内存泄露·memory profiler
未来猫咪花21 小时前
Everything is ViewModel:让状态管理回到对象世界
android·flutter·ios