SageAMDP
SageAMDP

Reputation: 431

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 channel 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.

Upvotes: 4

Views: 3178

Answers (1)

Bamandr
Bamandr

Reputation: 21

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.

Upvotes: 2

Related Questions