音频输出路线AirP​​lay播放 [英] Audio Output Routes for AirPlay

查看:169
本文介绍了音频输出路线AirP​​lay播放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过,但无法找到一种方法来访问音频输出路径,所以我可以检测,如果音频通过AirPlay的出来。

I have looked but can't find a way to access the Audio Output Routes so i can detect if the audio is coming out via AirPlay.

这是我在文档中找到适用于iOS 5.0

This is what i found in the Documentation for iOS 5.0

kAudioSessionOutputRoute_AirPlay

讨论

这些字符串用作kAudioSession_AudioRouteKey_Type键用于与kAudioSession_AudioRouteKey_Outputs阵列相关联的字典值

These strings are used as values for the kAudioSession_AudioRouteKey_Type key for the dictionary associated with the kAudioSession_AudioRouteKey_Outputs array.

我不能找到一种方式来获得进入kAudioSession_AudioRouteKey_Outputs阵列。

I can't find a way to get access to the kAudioSession_AudioRouteKey_Outputs array.

感谢

推荐答案

即使的Bassem似乎已经找到了解决方案,为完成的缘故,这里是如何检测的电流输出路由是否AirPlay的与否:

Even if Bassem seems to have found a solution, for completion's sake, here's how to detect whether the current output route is AirPlay or not:

- (BOOL)isAirPlayActive{
    CFDictionaryRef currentRouteDescriptionDictionary = nil;
    UInt32 dataSize = sizeof(currentRouteDescriptionDictionary);
    AudioSessionGetProperty(kAudioSessionProperty_AudioRouteDescription, &dataSize, &currentRouteDescriptionDictionary);
    if (currentRouteDescriptionDictionary) {
        CFArrayRef outputs = CFDictionaryGetValue(currentRouteDescriptionDictionary, kAudioSession_AudioRouteKey_Outputs);
        if (outputs) {
            if(CFArrayGetCount(outputs) > 0) {
                CFDictionaryRef currentOutput = CFArrayGetValueAtIndex(outputs, 0);
                CFStringRef outputType = CFDictionaryGetValue(currentOutput, kAudioSession_AudioRouteKey_Type);
                return (CFStringCompare(outputType, kAudioSessionOutputRoute_AirPlay, 0) == kCFCompareEqualTo);
            }
        }
    }

    return NO;
}

请记住,你必须#进口< AudioToolbox / AudioToolbox.h方式> ,反对AudioToolbox框架链接

Keep in mind that you have to #import <AudioToolbox/AudioToolbox.h> and link against the AudioToolbox framework.

这篇关于音频输出路线AirP​​lay播放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆