How to list available audio output route on iOS

前端 未结 2 630
我寻月下人不归
我寻月下人不归 2021-01-13 07:50

Now i\'d like to list available audio output route in my iPhone app, something like this:

http://www.blogcdn.com/www.tuaw.com/media/2008/09/cb(iphone-101_-switch-bet

相关标签:
2条回答
  • 2021-01-13 08:25

    there are only 5 audio input routes (iOS5+):

    kAudioSessionInputRoute_LineIn;
    kAudioSessionInputRoute_BuiltInMic;
    kAudioSessionInputRoute_HeadsetMic;
    kAudioSessionInputRoute_BluetoothHFP;
    kAudioSessionInputRoute_USBAudio;
    

    and there are 9 audio output routes (iOS5+):

    kAudioSessionOutputRoute_LineOut;
    kAudioSessionOutputRoute_Headphones;
    kAudioSessionOutputRoute_BluetoothHFP;
    kAudioSessionOutputRoute_BluetoothA2DP;
    kAudioSessionOutputRoute_BuiltInReceiver;
    kAudioSessionOutputRoute_BuiltInSpeaker;
    kAudioSessionOutputRoute_USBAudio;
    kAudioSessionOutputRoute_HDMI;
    kAudioSessionOutputRoute_AirPlay;
    

    find more information here how you can check the availability of them in your application.

    0 讨论(0)
  • 2021-01-13 08:26

    I got something working using MPVolumeView . This component has a button that lets you choose the output audio route, like in the Music App.

    If you want you can hide the slider (and have only the button) using:

    self.myMPVolumeView.showsVolumeSlider = NO;
    

    At the moment I cannot find a way to obtain the output destinations and input sources programmatically as I pointed out in this question List available output audio target AVAudioSession

    0 讨论(0)
提交回复
热议问题