zoukankan      html  css  js  c++  java
  • ios get airplay name

    tarting from iOS7 AudioToolbox API for currentRoute becomes deprecated:

    Apple instead made currentRoute API available to you in AudioSession, which allows retrieving it's port information as well as listening to audioRouteChangeNotification in a nice way:

    NSString* airplayName = [self activeAirplayOutputRouteName];
    if (airplayName) {
        //airplay is active
    
    }
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioRouteHasChangedNotification:) name:AVAudioSessionRouteChangeNotification object:[AVAudioSession sharedInstance]];
     1 - (NSString*)activeAirplayOutputRouteName
     2 {
     3     AVAudioSession* audioSession = [AVAudioSession sharedInstance];
     4     AVAudioSessionRouteDescription* currentRoute = audioSession.currentRoute;
     5     for (AVAudioSessionPortDescription* outputPort in currentRoute.outputs){
     6         if ([outputPort.portType isEqualToString:AVAudioSessionPortAirPlay])
     7             return outputPort.portName;
     8     }
     9 
    10     return nil;
    11 }
    12 
    13 - (void)audioRouteHasChangedNotification:(NSNotification*)notification
    14 {
    15     //do something
    16 }
  • 相关阅读:
    Visual Studio for Mac 2017 初体验
    利用栈求表达式的值
    Problem C: ChongQueue
    Problem G: ZL's Prob.2
    Problem F: ZL's Prob.1
    Problem B: ChongBit
    HDU 5156
    SHUOJ 1771
    OpenGL学习整理------着色器
    OpenGL ES着色器语言----------------储存修饰符
  • 原文地址:https://www.cnblogs.com/XCoderLiu/p/4647887.html
Copyright © 2011-2022 走看看