- (voID)playMovIE:(Nsstring *)name :(Nsstring *)type{ NSURL *movIEURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:name ofType:type]]; self.movIEAsset = [AVAsset assetWithURL:movIEURL]; self.movIEItem = [[AVPlayerItem alloc] initWithAsset:self.movIEAsset]; self.movIEPlayer = [[AVPlayer alloc] initWithPlayerItem:self.movIEItem]; self.movIEPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone; self.movIELayer.vIDeoGravity = AVLayerVIDeoGravityResize; self.movIELayer = [AVPlayerLayer playerLayerWithPlayer:self.movIEPlayer]; [self.movIELayer setFrame:self.vIEw.frame]; [self.vIEw.layer addSublayer:self.movIELayer]; [self.movIEPlayer addobserver:self forKeyPath:@"status" options:0 context:nil]; // Schedule stop after 6 seconds [NSTimer scheduledTimerWithTimeInterval:6.0 target:self selector:@selector(stopCurrentMovIE:) userInfo:nil repeats:NO];}
视频正在播放,但它不会在整个屏幕上填充(如果需要的话),但它只调整大小以保持其宽高比:我已经尝试了“vIDeoGravity”的所有三个值…似乎没有任何改变.
我怎么解决?
谢谢
- (voID)playMovIE:(Nsstring *)name :(Nsstring *)type{ NSURL *movIEURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:name ofType:type]];self.movIEAsset = [AVAsset assetWithURL:movIEURL];self.movIEItem = [[AVPlayerItem alloc] initWithAsset:self.movIEAsset];self.movIEPlayer = [[AVPlayer alloc] initWithPlayerItem:self.movIEItem];self.movIELayer = [AVPlayerLayer playerLayerWithPlayer:self.movIEPlayer];[self.movIELayer setFrame:self.vIEw.frame];self.movIEPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;self.movIELayer.vIDeoGravity = AVLayerVIDeoGravityResize;[self.vIEw.layer addSublayer:self.movIELayer];[self.movIEPlayer addobserver:self forKeyPath:@"status" options:0 context:nil];// Schedule stop after 6 seconds[NSTimer scheduledTimerWithTimeInterval:6.0 target:self selector:@selector(stopCurrentMovIE:) userInfo:nil repeats:NO];}总结
以上是内存溢出为你收集整理的ios – 在AVPlayerLayer上拉伸视频全部内容,希望文章能够帮你解决ios – 在AVPlayerLayer上拉伸视频所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)