AVPlayerLayer

来源:互联网 发布:工商银行博士后 知乎 编辑:程序博客网 时间:2024/04/28 02:03

关于avplayer的用法


原文地址:http://blog.sina.com.cn/s/blog_6de1899201012p8z.html


NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"filename" ofType:@"type"];

self.player = [AVPlayer playerWithURL:[NSURL fileURLWithPath:moviePath]];

[self.player play];

 

// Create and configure AVPlayerLayer

AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player];

playerLayer.bounds = CGRectMake(0, 0, 300, 170);

playerLayer.position = CGPointMake(160, 150);

playerLayer.borderColor = [UIColor whiteColor].CGColor;

playerLayer.borderWidth = 3.0;

playerLayer.shadowOffset = CGSizeMake(0, 3);

playerLayer.shadowOpacity = 0.80;

 CATransform3D t = CATransform3DIdentity;

    t.m34 = - 1.0 / 1000;

self.view.layer.sublayerTransform = t;

[self.view.layer addSublayer:playerLayer];


//change layer rotate

//CALayer *layer = [[self.view.layer sublayers] objectAtIndex:0];

// layer.transform = CATransform3DMakeRotation([sender value], 0, 1, 0);


//change layer transform.rotation.x

// CALayer *layer = [[self.view.layer sublayers] objectAtIndex:0];

// CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];

// animation.duration = 1.25f;

// animation.toValue = [NSNumber numberWithFloat:DEGREES_TO_RADIANS(360)];

// [layer addAnimation:animation forKey:@"spinAnimation"];


原创粉丝点击