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

相关推荐
00后程序员张4 小时前
对比 Ipa Guard 与 Swift Shield 在 iOS 应用安全处理中的使用差异
android·开发语言·ios·小程序·uni-app·iphone·swift
悠哉清闲6 小时前
不同车型drawable不同
android·开发语言
三十_A7 小时前
前端技术分享:基于 Canvas 实现视频帧截取与下载方案
前端·音视频
地狱为王7 小时前
Unity使用NovaSR将沉闷的16kHz音频升频成清晰的48kHz音频
unity·游戏引擎·音视频·novasr
Dreams°1237 小时前
进阶实战:Wan2.2-T2V-A5B 实现可点击跳转的互动式教育视频
算法·microsoft·ai·音视频
00后程序员张8 小时前
在 iOS 设备上同时监控 CPU、GPU 与内存的方法
android·ios·小程序·https·uni-app·iphone·webview
测试_AI_一辰8 小时前
项目实践笔记 9:打卡/日报Agent项目Bug 修改与稳定性收口(v1.0)
android·开发语言·人工智能·功能测试·ai编程·ab测试
马 孔 多 在下雨8 小时前
Kotlin协程进阶王炸之作-Kotlin的协程到底是什么
android·开发语言·kotlin
冬奇Lab9 小时前
【Kotlin系列15】多平台开发实战:一次编写,多端运行
android·开发语言·kotlin
Dxy12393102169 小时前
告别默认排序:MySQL自定义排序的“炼金术”
android·数据库·mysql