我正在尝试查看具有 alpha 通道的视频女巫(背景是透明的)。唯一的问题是我似乎不知道如何使播放器的背景透明。我知道我必须使用 AVplayer,但我无法访问它的 .view 属性。如何将其添加到子视图并添加图层?
NSString *path = [NSString stringWithFormat:@"%@%@", [[NSBundle mainBundle] resourcePath], @"/New Project 5.m4v"];
NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
moviePlayer = [[AVPlayer alloc] initWithURL:filePath];
AVPlayerLayer* playerLayer = [AVPlayerLayer playerLayerWithPlayer:moviePlayer];
self.playerLayer.frame = self.view.bounds;
moviePlayer.view.alpha = 0.3;
[moviePlayer.layer addSublayer:playerLayer];
[moviePlayer play];