AVPlayerLayer with alpha mask

Has anyone got a video played on AVPlayerLayer with alpha?

If so, how is this possible? I tried many different solutions, including using a pure alpha channel, applying blending modes to the target layer and the animation of each frame itself. The only workable solution is the latter, and he boxed the phone too much.

+3
source share
1 answer

i use a 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 a PNG file with transparency.

+1
source

Source: https://habr.com/ru/post/1753550/


All Articles