4

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

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

4

1 回答 1

2

我用面膜,

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 文件。

于 2010-11-30T13:50:21.987 回答