gpt4 book ai didi

ios - 是否可以以编程方式启用 airplay 镜像?

转载 作者:可可西里 更新时间:2023-11-01 00:07:09 25 4
gpt4 key购买 nike

关于这个问题,我已经看了很多,但我发现的所有问题都已经过时了。

example

this article is from 2012 and says that it's not possible

基本上,我希望能够在我的应用程序中通过 airplay 将我的 iPhone 镜像到另一个屏幕,我想知道现在是否可行。我找到的文章都说这是不可能的,或者如果完成了,该应用程序将不会被应用程序商店接受。

最佳答案

从 iOS 11 开始,可以实现自己的 AirPlay 选择器 View 。请查看 AVRoutePickerView .它将允许您在应用程序内控制与不同 AppleTV/外部屏幕的连接。参见示例:

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];

AVRoutePickerView *routePickerView = [[AVRoutePickerView alloc] initWithFrame:CGRectMake(0.0f, 30.0f, 30.0f, 30.0f)];
routePickerView.backgroundColor = [UIColor lightGrayColor];
[self.view addSubview:routePickerView];

AVAsset *asset = [AVAsset assetWithURL:[NSURL URLWithString:@"https://bitdash-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8"]];
AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithAsset:asset];
AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
[playerLayer setFrame:CGRectMake(0.0f, 40.0f, self.view.frame.size.width, self.view.frame.size.height - 40.0f)];
[self.view.layer addSublayer:playerLayer];
[player seekToTime:kCMTimeZero];
[player play];
}

@end

结果是按下 AVRoutePickerView 你会得到这样的东西: enter image description here

通过按下可用的外部屏幕,您将能够在其上播放内容。

关于ios - 是否可以以编程方式启用 airplay 镜像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38045488/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com