iphone – 带alpha蒙版的AVPlayerLayer

有没有人在带有alpha通道的AVPlayerLayer上播放视频?

如果是这样,怎么可能?我尝试了许多不同的解决方案,包括使用纯alpha通道视频,将混合模式应用于目标图层并自己动画每一帧.唯一可行的解​​决方案是后者,它使手机陷入太多困境.

最佳答案 我用面膜,

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是具有透明度的png文件.

点赞