AVPlayerLayer with alpha mask
Has anyone got a video playing on an AVPlayerLayer with an alpha channel?
If so, how is it possible? I've tried many different solutions including using pure alpha channe开发者_JAVA百科l video, applying blend modes to the target layer and animating every frame myself. 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.
精彩评论