简体   繁体   English

带有Alpha蒙版的AVPlayerLayer

[英]AVPlayerLayer with alpha mask

Has anyone got a video playing on an AVPlayerLayer with an alpha channel? 有人在带有Alpha通道的AVPlayerLayer上播放过视频吗?

If so, how is it possible? 如果是这样,怎么可能? I've tried many different solutions including using pure alpha channel video, applying blend modes to the target layer and animating every frame myself. 我尝试了许多不同的解决方案,包括使用纯alpha通道视频,将混合模式应用于目标图层以及为每个帧设置动画。 The only workable solution is the latter and it bogs the phone down too much. 唯一可行的解​​决方案是后者,它会使电话停顿得太多。

i use mask, 我用口罩

NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: file];

AVURLAsset* url = [AVURLAsset URLAssetWithURL:fileURL options:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:AVURLAssetPreferPreciseDurationAndTimingKey]];

AVPlayerItem* pitem = [AVPlayerItem playerItemWithAsset:url1];
AVPlayer*player  = [AVPlayer playerWithPlayerItem:pitem1];

pv = [[PlayerView alloc] initWithFrame:CGRectMake(0,0, 100, 100)];
[pv setPlayer:player];

UIImageView*iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mask"]];
pv.layer.mask = iv.layer;

mask is png-file with transparency. 遮罩是具有透明度的png文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM