大佬教程收集整理的这篇文章主要介绍了视频循环在某些时候冻结了我的iOS应用程序,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
以下是运行14小时后的仪器会话:
我对仪器还不是很熟悉,虽然Live Bytes保持一致且低,但其他值似乎非常高.但同样,我不确定这是否正常.
这就是我创建视频播放器的方式:
- (void)setupInitialContentWithBounds:(CGRect)externalScreenBounds { avPlayer = [[AVPlayer alloc] init]; avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:avPlayer]; avPlayerLayer.frame = externalScreenBounds; [self.externalWindow.layer addSublayer:avPlayerLayer]; avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone; [[NsnotificationCenter defaultCenter] addObserver:self SELEctor:@SELEctor(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:[avPlayer currentItem]]; [self playVideo:@"Idle"]; }
这是playVideo方法:
- (void)playVideo:(NSString *)name { currentVideo = name; NSString *filepath = [[NSBundle mainBundle] pathForresource:name ofType:@"mp4"]; NSURL *fileURL = [NSURL fileURLWithPath:filepath]; AVPlayerItem *playerItem = [[AVPlayerItem alloc] initWithURL:fileURL]; [avPlayer replaceCurrentItemWithPlayerItem:playerItem]; [avPlayer play]; }
这里是视频结束时的通知监听器:
- (void)playerItemDidReachEnd:(Nsnotification *)notification { if([currentVideo isEqualToString:@"Idle"]) { //Keeps looping the Idle video until another one is SELEcted AVPlayerItem *p = [notification object]; [p seektotime:kCMTimeZero]; } else { NSLog(@"Just finished a different video,so go BACk to idle"); [self playVideo:@"Idle"]; } }
编辑:起初我的客户告诉我它崩溃了,但看起来它实际上冻结了,视频停止播放,应用程序没有响应.有任何想法吗?
以上是大佬教程为你收集整理的视频循环在某些时候冻结了我的iOS应用程序全部内容,希望文章能够帮你解决视频循环在某些时候冻结了我的iOS应用程序所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。