![](/img/trans.png)
[英]Is it possible to Redirect audio output to phone speaker or headset in iOS programmatically
[英]iOS 7 Get all the available audio devices (bluetooth, headset, speaker, phone)
期望的功能:
這就像iPhone本機手機應用程序。 當藍牙/耳機連接到iPhone時,揚聲器按鈕(通常只有揚聲器/電話切換)將顯示所有可用的音頻輸出設備。 默認使用藍牙。 用戶可以選擇其他設備播放聲音。
問題:
如何檢測連接到iPhone的所有可用音頻設備?
如何更新路由並將音頻輸出設置為所選設備?
請注意,使用AudioSessionGetProperty和AudioSessionSetProperty的現有解決方案可能並不理想,因為iOS7不推薦使用這兩種方法。
既然沒有回應。 我開始基於Jawbone的AudioSessionManager編寫自己的庫。
關於這兩個問題
我仍然找不到獲得可用輸出的方法。 但是AVAudioSession確實支持來自iOS7的屬性availableInputs。
AVAudioSession有一個routeChange通知。 你可以捕捉到不同的路線變化原因並妥善處理。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(currentRouteChanged :) name:AVAudioSessionRouteChangeNotification object:nil];
完整的實現是在我的github 回購 。 歡迎反饋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.