seb*_*ich 2 iphone objective-c ipad ios airplay
我有问题要检查我是否连接到airplay设备,以及是否通过镜像或流连接.但检查需要在视频开始之前完成.
如果视频已经启动,airPlayVideoActive仅返回YES.
seb*_*ich 18
这是我的解决方案
- (BOOL)isAudioSessionUsingAirplayOutputRoute
{
/**
* I found no other way to check if there is a connection to an airplay device
* airPlayVideoActive is NO as long as the video hasn't started
* and this method is true as soon as the device is connected to an airplay device
*/
AVAudioSession* audioSession = [AVAudioSession sharedInstance];
AVAudioSessionRouteDescription* currentRoute = audioSession.currentRoute;
for (AVAudioSessionPortDescription* outputPort in currentRoute.outputs){
if ([outputPort.portType isEqualToString:AVAudioSessionPortAirPlay])
return YES;
}
return NO;
}
Run Code Online (Sandbox Code Playgroud)
要检查airplay连接是否镜像,您只需检查屏幕计数.
if ([[UIScreen screens] count] < 2)) {
//streaming
}
else {
//mirroring
}
Run Code Online (Sandbox Code Playgroud)
如果有更好的解决方案,请告诉我
| 归档时间: |
|
| 查看次数: |
4567 次 |
| 最近记录: |