Created
July 25, 2014 18:01
-
-
Save takkumattsu/3f168bf768bcb5d5b497 to your computer and use it in GitHub Desktop.
外部出力(AirPlay/HDMI)をAVPlayerを使わずに検知する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)isExternalPlayback | |
{ | |
__block BOOL isExternalOutput = NO; | |
// 入出力を取得 | |
AVAudioSessionRouteDescription *audioRouteDesc = [[AVAudioSession sharedInstance] currentRoute]; | |
// 出力を取得 | |
NSArray *outputs = audioRouteDesc.outputs; | |
[outputs enumerateObjectsUsingBlock:^(AVAudioSessionPortDescription *audioDesc, NSUInteger idx, BOOL *stop) { | |
if([audioDesc.portType isEqualToString:AVAudioSessionPortAirPlay]){ | |
NSLog(@"AirPlay(๑˃̵ᴗ˂̵)ﻭ"); | |
*stop = YES; | |
isExternalPlayback = YES; | |
} else if ([audioDesc.portType isEqualToString:AVAudioSessionPortHDMI]){ | |
NSLog(@"HDMI(。╹ω╹。)"); | |
*stop = YES; | |
isExternalOutput = YES; | |
} else { | |
// その他 | |
} | |
}]; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment