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

相关推荐
李新_21 分钟前
基于Markwon封装Markdown组件
android·aigc·markdown
JS-s37 分钟前
【无标题】
音视频
Non-existent9873 小时前
Flutter + FastAPI 30天速成计划自用并实践-第10天-组件化开发实践
android·flutter·fastapi
山海青风3 小时前
语音合成 - 用 Python 合成藏语三大方言语音
开发语言·python·音视频
@老蝴4 小时前
MySQL数据库 - 约束和联合查询
android·数据库·mysql
ljt27249606615 小时前
Compose笔记(六十一)--SelectionContainer
android·笔记·android jetpack
有位神秘人5 小时前
Android中Compose系列之按钮Button
android
AI科技摆渡6 小时前
GPT-5.2介绍+ 三步对接教程
android·java·gpt
csdn12259873366 小时前
Android12 新启动页到底该怎么做
android·启动页
aaajj7 小时前
【Android】关于MY_PACKAGE_REPLACED广播
android