Tag: avplayerlayer

AVPlayer不显示video

我想在游戏开始时播放电影。 我正在使用AVPlayer来做到这一点。 我的问题是,当我注册一个KVO来检查我的AVPlayer的状态时,我的游戏照常进行,没有等待video加载和完成。 因此,我只能听到我的.mov文件中的audio,并且看不到任何video(因为我的游戏已经开始)。 我希望video加载和完成之前进行游戏。 代码如下: @interface RMVideoView : NSView { NSURL* _videoURL; AVPlayer* _player; AVPlayerLayer* _playerLayer; } @property (nonatomic, readonly, strong) AVPlayer* player; @property (nonatomic, readonly, strong) AVPlayerLayer* playerLayer; @property (nonatomic, retain) NSURL* videoURL; – (void) play; @end static void *RMVideoViewPlayerLayerReadyForDisplay = &RMVideoViewPlayerLayerReadyForDisplay; static void *RMVideoViewPlayerItemStatusContext = &RMVideoViewPlayerItemStatusContext; @interface RMVideoView() – (void)onError:(NSError*)error; – (void)onReadyToPlay; […]

隐藏Quicktime Logo / AVPlayerViewControllerContentView图像

从avplayer中隐藏AVPlayerViewControllerContentView图像,因为它有时出现并且卡住了用户。 请find图像: –

AVPlayer空白video:播放声音,但没有video

这个问题有同样的问题,但解决scheme没有奏效。 AVPlayer有时播放空白video:有声音但没有video。 播放空白video时,我们打印了播放器的框架和状态。 该框架是非零,并正确设置。 状态也readyToPlay 。 playfunction也在主线程上调用。 换句话说,玩家层的框架是有效的,并且玩家也准备好玩。 然而,即使声音没有出现,也不会出现video。 这个问题似乎是一个时机。 如果我们在播放video前等待5-10秒,则video每次都能正常播放。 此问题出现在iOS 10上,而不是iOS 8或9上。 苹果论坛上的这个post表明这可能是一个与AVVideoCompositionCoreAnimationTool有关的bug,我们也使用它。 任何解决scheme 在iPhone 7设备上这比iPhone 5s设备更频繁地发生。 码: fileprivate func playVideo(_ videoURL: String, prompt: String) { // Show <playerView> playerView.isHidden = false // Use new video in player playerItem = AVPlayerItem(url: URL(fileURLWithPath: videoURL)) print("STATUS: \(player.status == AVPlayerStatus.readyToPlay). FRAME: \(playerLayer.frame). MAIN THREAD: \(Thread.isMainThread)") player.replaceCurrentItem(with: […]

通过覆盖GIF图像保存video

我正在制作一个录制video的应用程序。 录制完成后,我使用Library将GIF图像放在上面。 我的代码播放video和GIF图像作为覆盖 self.avPlayer = [AVPlayer playerWithURL:self.urlstring]; self.avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone; AVPlayerLayer *videoLayer = [AVPlayerLayer playerLayerWithPlayer:self.avPlayer]; videoLayer.frame = self.preview_view.bounds; videoLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; [self.preview_view.layer addSublayer:videoLayer]; NSURL *url = [[NSBundle mainBundle] URLForResource:@"02" withExtension:@"gif"]; self.img_gif.image = [UIImage animatedImageWithAnimatedGIFData:[NSData dataWithContentsOfURL:url]]; 但是现在我想合并并保存这个GIF图像覆盖的video。 我谷歌没有find我想要的。 感谢您的帮助

AVPlayervideo空白,但听到声音

我从MPMoviePlayerController切换到AVPlayer因为我需要更好地控制video交换。 我用MPMoviePlayerController播放的.mov文件MPMoviePlayerController不错,但在切换到AVPlayer后,我听到video中的audio,但video只是显示了我添加了AVPlayerLayer的视图背景。 以下是我如何初始化AVPlayer 。 self.player = [[AVPlayer alloc] initWithURL:video]; AVPlayerLayer* playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player]; playerLayer.frame = self.playerContainer.bounds; [self.playerContainer.layer addSublayer:playerLayer]; 后来我只是发一个。 [self.player play]; 当video播放时,我听到audio,但看不到video。 我也尝试将zPosition设置为不幸。 playerLayer.zPosition = 1;

AVPlayerLayer获取图像到UIImageView缓冲区

我尝试[playerLayer renderInContext:UIGraphicsGetCurrentContext()]; 它会显示黑色的背景。 所以我得到当前播放器项目作为连续的重击图像它不像video播放只是静止图像不断stream动。 所以还有其他的select吗?

AVPlayer失败,AVPlayerItemStatusFailed(OSStatus错误-12983)

有时,AVPlayer失败, AVPlayerItemStatusFailed失败,AVPlayer继续失败, AVPlayerItemStatusFailed 。 我试图清除AVPlayer实例并创build一个新的,但我不能实现AVPlayerItemStatusFailed失败解决。 此外,使用AVPlayer实例removingFromSuperview UIView并使用AVPlayer初始化新项目并不能解决问题。 所以我想,AVPlayer不能完全清除。 有没有人build议尝试彻底清除AVPlayer,并使其在失败后工作? 错误日志: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x1a689360 {NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x1a688e70 "The operation couldn't be completed. (OSStatus error -12983.)", NSLocalizedFailureReason=An unknown error occurred (-12983)} UPD。 对于@matt playerItem = [AVPlayerItem playerItemWithURL:[NSURL fileURLWithPath:filePath.path]]; if (!self.avPlayer) { avPlayer = [AVPlayer playerWithPlayerItem:playerItem]; } […]

当创build了太多的AVPlayer实例时,AVPlayerItemStatusFailed错误

我正在创build一个iOS应用程序,该应用程序创build用户池提交的所有video的供稿,使用户能够浏览和查看其他人创build的video。 正如您所想象的,我需要能够支持Feed中的任意数量的video。 目前,我正在为每个video创build和保留一个AVPlayer实例,如下所示: //inside the init method of a UIView //create the AVPlayer and store it in a strong property NSString * urlString = @"aRemoteURL.mov"; NSURL * movURL = [NSURL URLWithString:urlString]; _videoPlayer = [[AVPlayer alloc]initWithURL:movURL]; //register callbacks for handling buffering [_videoPlayer.currentItem addObserver:self forKeyPath:@"playbackBufferEmpty" options:NSKeyValueObservingOptionNew context:nil]; [_videoPlayer.currentItem addObserver:self forKeyPath:@"playbackLikelyToKeepUp" options:NSKeyValueObservingOptionNew context:nil]; //add the AVPlayerLayer to the […]

iOS的AVPlayer放缓

我正在使用AVPlayer在我的项目中播放在线video。 video播放良好。 现在我想减less/增加video的fps。 以下是我正在使用的代码: self.asset = [AVAsset assetWithURL:self.videoUrl]; // the video player self.player = [AVPlayer playerWithURL:self.videoUrl]; self.player.actionAtItemEnd = AVPlayerActionAtItemEndNone; self.playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player]; self.playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:[self.player currentItem]]; self.playerLayer.frame = CGRectMake(0, 0, self.view.frame.size.width, self.myPlayerView.frame.size.height); [self.myPlayerView.layer addSublayer:self.playerLayer]; – (void)playerItemDidReachEnd:(NSNotification *)notification { AVPlayerItem *p = [notification object]; [p seekToTime:kCMTimeZero]; } 现在应该如何减less/增加在线video的fps?

应用程序激活后恢复AVPlayervideo播放

我从AVPlayer编写自定义播放器进行video播放。 根据苹果公司的文档设置video层: self.player = [IPLPlayer new]; self.player.playerLayer = (AVPlayerLayer *)self.playerView.layer; self.playerView是这些文档中的常见类: @implementation PlayerView + (Class) layerClass { return [AVPlayerLayer class]; } – (AVPlayer *)player { return [(AVPlayerLayer *)[self layer] player]; } – (void)setPlayer:(AVPlayer *) player { [(AVPlayerLayer *) [self layer] setPlayer:player]; } 问题是:当closures应用程序(主页button)或阻止屏幕时,video播放停止,当继续播放audio播放时,屏幕上的图像仍然是阻止屏幕之前的图像 – 完全静态并且注意更改帧。 屏幕被屏蔽后如何恢复VIDEO播放? 似乎我必须注册通知,并在应用程序成为活动后恢复video层: -(void)registerNotification { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willEnterBackground) name:UIApplicationWillResignActiveNotification object:nil]; […]