假设下面的代码,我将如何在movieView中显示mov?我是否需要以这种方式对AVPlayer进行子类化,或者是否有更简单的方法来实现这一目标?
UIView *movieView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 480, 1080)];
movieView.backgroundColor = [UIColor redColor];
[self.view addSubview:movieView];
NSURL *url = [[NSBundle mainBundle]URLForResource:@"Clock_stroke_04_Full" withExtension:@"mov"];
self.player = [AVPlayer playerWithURL:url];
[self.playerView setMovieToPlayer:self.player];
[self.player play];
@implementation AVPlayerClass
+ (Class)layerClass
{
return [AVPlayerLayer class];
}
- (AVPlayer*)player
{
return [(AVPlayerLayer*)[self layer] player];
}
-(void)setMovieToPlayer:(AVPlayer *)player
{
[(AVPlayerLayer*)[self layer] setPlayer:player];
}
@property (nonatomic, retain) AVPlayer *player;
@property (nonatomic, retain) AVPlayerClass *playerView;
答案 0 :(得分:2)
RInside.h
请尝试运行此代码。谢谢