大佬教程收集整理的这篇文章主要介绍了ios – 在AVPlayerLayer上拉伸视频,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
- (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上拉伸视频所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。