Detect attached audio devices iOS

后端 未结 3 922
一整个雨季
一整个雨季 2021-01-12 06:36

I\'m trying to figure out how to detect which if any audio devices are connected on iphone/ipad/ipod. I know all about the audio route calls and route change callbacks but t

3条回答
  •  走了就别回头了
    2021-01-12 06:53

    In case of iOS 5 you should use:

    CFStringRef newRoute;
    size = sizeof(CFStringRef);
    XThrowIfError(AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &size, &newRoute), "couldn't get new audio route");
    if (newRoute)
    {
        CFShow(newRoute);
        if (CFStringCompare(newRoute, CFSTR("HeadsetInOut"), NULL) == kCFCompareEqualTo) // headset plugged in
              {
                colorLevels[0] = .3;                
                colorLevels[5] = .5;
              }
        else if (CFStringCompare(newRoute, CFSTR("SpeakerAndMicrophone"), NULL) == kCFCompareEqualTo)
    }
    

提交回复
热议问题