iphone - 带有 alpha 掩码的 AVPlayerLayer

标签 iphone objective-c avfoundation

有没有人在带有 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/

相关文章:

iphone - iPhone 编程中属性的使用

iphone - 找到结束/结束坐标你一个 UISwipeGestureRecognizer

swift3 - Swift 3 声音播放

ios - AudioUnitInitialize 导致 iOS 模拟器上出现 Allow Microphone access 提示

ios - SKVideoNode 中的视频在 Xcode 模拟器中工作正常,但无法在大多数设备上播放

iphone - 在 NSFetchedResultsController 跟踪更改时重置 NSPersistentStore 后崩溃

iphone - 显示图像和字符串的 UIPIckerView

iphone - 带缩放 mapView 的点触摸

iphone - 以动画方式删除 UITableViewCell 附件

ios - NSNotificationCenter 和 didReceiveRemoteNotification