我目前正在通过AudioQueues播放音频。我希望允许用户连接到Airplay设备。
如果我创建了一个MPVolumeView并使用'showsRouteButton‘显示路由按钮,我就可以成功连接。
有没有一种方法可以在不使用MPVolumeView的情况下将音频路由更改为Airplay?或者是一个更简单的苹果视图,只是一个路由按钮?
发布于 2012-01-13 01:58:52
我不认为有任何其他方式来显示airplay路由按钮(至少在当前的SDK iOS 5.1中)。如果你想显示AirPlay选项,你必须使用MPVolumeView..
发布于 2013-09-03 23:12:50
1隐藏MPVolumeView并将其设置为全局变量
CGRect frame = CGRectZero;
frame.origin.y = 0;
frame.origin.x = 410; // out of the screen
_volumeView = [[MPVolumeView alloc] initWithFrame:frame];
[_volumeView setShowsVolumeSlider:NO];
[_volumeView setShowsRouteButton:YES];
[self.view addSubview:_volumeView];2个模拟按钮磁带
- (IBAction)handleAirPlay:(id)sender {
for (UIButton *button in _volumeView.subviews)
{
if ([button isKindOfClass:[UIButton class]])
{
[button sendActionsForControlEvents:UIControlEventTouchUpInside];
}
}
}发布于 2020-02-19 19:35:09
从iOS 11开始,您可以使用AVRoutePicker:
import AVKit
let rpv = AVRoutePickerView()
view.addSubview(rpv)https://stackoverflow.com/questions/8825361
复制相似问题