HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了视频循环在某些时候冻结了我的iOS应用程序大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个在Kiosk上运行的应用程序,打开全天循环播放的视频.最终,大约1天后,应用程序冻结.

以下是运行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"];
    }
}

编辑:起初我的客户告诉我它崩溃了,但看起来它实际上冻结了,视频停止播放,应用程序没有响应.有任何想法吗?

解决方法

我不能回答你关于崩溃的问题,除了确认我们在这里看到类似的崩溃可能是同一个问题.

但是我可以帮助你更好地解释乐器的显示效果.我不担心整体字节数和#总体值非常高.这些测量自应用程序启动以来(或自附加仪器以来)分配的内存总量.也就是说,分配1MB然后释放它将为这些总数增加1MB.

我希望整体字节数量或多或少与视频*播放次数的大小成正比.

大佬总结

以上是大佬教程为你收集整理的视频循环在某些时候冻结了我的iOS应用程序全部内容,希望文章能够帮你解决视频循环在某些时候冻结了我的iOS应用程序所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。