有没有人在带有 alpha channel 的 AVPlayerLayer 上播放视频?
如果可以,那怎么可能呢?我尝试了许多不同的解决方案,包括使用纯 alpha channel 视频、将混合模式应用于目标层以及自己为每一帧制作动画。唯一可行的解决方案是后者,它会使手机停滞不前。
最佳答案
我用面膜,
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;
蒙版是透明的 png 文件。
关于iphone - 带有 alpha 掩码的 AVPlayerLayer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3196495/