简体   繁体   English

iOS 7获取所有可用的音频设备(蓝牙,耳机,扬声器,手机)

[英]iOS 7 Get all the available audio devices (bluetooth, headset, speaker, phone)

Desired feature: 期望的功能:

It's something like iPhone native phone app. 这就像iPhone本机手机应用程序。 When there are bluetooth/headset connected to iPhone, the speaker button (usually only speaker/phone toggle) will show you all the available audio output devices. 当蓝牙/耳机连接到iPhone时,扬声器按钮(通常只有扬声器/电话切换)将显示所有可用的音频输出设备。 Default using Bluetooth. 默认使用蓝牙。 User can select another device to play the sound. 用户可以选择其他设备播放声音。

Problem: 问题:

  1. How can I detect all the available audio devices connected to an iPhone? 如何检测连接到iPhone的所有可用音频设备?

  2. How can I update the route and set audio output to selected device? 如何更新路由并将音频输出设置为所选设备?

Note that existing solution with AudioSessionGetProperty AND AudioSessionSetProperty may not be ideal because these two methods are deprecated from iOS7. 请注意,使用AudioSessionGetProperty和AudioSessionSetProperty的现有解决方案可能并不理想,因为iOS7不推荐使用这两种方法。

Since no response. 既然没有回应。 I started to write my own library based on Jawbone's AudioSessionManager. 我开始基于Jawbone的AudioSessionManager编写自己的库。

Regarding the two problems 关于这两个问题

  1. I still can't find ways to get available outputs. 我仍然找不到获得可用输出的方法。 but AVAudioSession do supports property availableInputs from iOS7. 但是AVAudioSession确实支持来自iOS7的属性availableInputs。

  2. AVAudioSession has a routeChange notification. AVAudioSession有一个routeChange通知。 you can catch different route change reason and handle it properly. 你可以捕捉到不同的路线变化原因并妥善处理。

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(currentRouteChanged:) name:AVAudioSessionRouteChangeNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(currentRouteChanged :) name:AVAudioSessionRouteChangeNotification object:nil];

The full implementation is in my github repo . 完整的实现是在我的github 回购 Feedback is welcomed. 欢迎反馈。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以通过编程将音频输出重定向到iOS中的手机扬声器或耳机 - Is it possible to Redirect audio output to phone speaker or headset in iOS programmatically 使用手机录制音频,但通过iOS中的蓝牙耳机播放录制 - Record audio with phone, but play record through bluetooth headset in iOS 在iOS中以编程方式将呼叫音频路由从蓝牙耳机更改为iPhone扬声器 - Change Call Audio routing from Bluetooth Headset to iPhone Speaker in iOS programatically iOS - 可以录制蓝牙耳机麦克风的音频并播放设备扬声器 - iOS - is possible to record audio from Bluetooth headset mic and play in device speaker 如何获取可用的输出音频源列表(扬声器,耳机,蓝牙) - How to get list of available output audio source ( Speaker, earphone, bluetooth ) 从无线耳机录制音频并通过蓝牙扬声器播放 - Record Audio From wireless Headset and Play it Through Bluetooth speaker 如何获取ios swift中可用蓝牙设备的名称列表? - How to get list of names of available bluetooth devices in ios swift? iOS:如何在音乐应用程序中的蓝牙耳机中播放缓冲音频? - iOS: How to play buffering audio in bluetooth headset in my music app? 蓝牙耳机无法用作iOS和OpenEars的音频录制捕获 - BlueTooth headset not able to use as audio recording capture for iOS and OpenEars iOS-如何使用蓝牙耳机作为音频输入来录制视频? - iOS - How to record a video using a bluetooth headset as audio input?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM