UIViewController インスタンスのバックグラウンドでビデオを再生するために AVPlayerLayer を使用しています。iPhone でアプリを起動したときに、虫眼鏡が間違った方法で表示されることに気付きました。動画仕様:H.264、AAC、640×360、MOV。
ビデオサブレイヤーなしの拡大鏡の描画内の背景。サブビュー (ボタン、テキスト フィールドなど) だけが虫眼鏡の中に描画されています。
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor yellowColor];
NSURL *videoURL = [[NSBundle mainBundle] URLForResource:@"bf4" withExtension:@"mov"];
AVAsset *asset = [AVAsset assetWithURL:videoURL];
AVPlayerItem *item = [AVPlayerItem playerItemWithAsset:asset];
AVPlayer *player = [AVPlayer playerWithPlayerItem:item];
player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
UIView *container = [[UIView alloc] initWithFrame:self.view.bounds];
container.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:container];
AVPlayerLayer *layer = [AVPlayerLayer playerLayerWithPlayer:player];
[container.layer addSublayer:layer];
layer.frame = container.bounds;
layer.videoGravity = AVLayerVideoGravityResizeAspectFill;
[self.view bringSubviewToFront:self.textField];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[player play];
});
}
これを防ぐ方法を知っている人はいますか?