我有一個應用程序正在Kiosk上運行,打開全天循環視頻。最終,大約1天后,應用程序凍結。視頻循環凍結了我的iOS應用程序
這裏是14小時的運行後的儀器會話:
我不是很熟悉儀器着呢,雖然現場字節保持一致,併爲低,其他數值似乎非常高。但是,我不確定這是否正常。
這是我如何創建視頻播放器:
- (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"];
}
}
編輯:起初我的客戶告訴我它墜毀,但它看起來像它實際上凍結,視頻停止p鋪設和應用程序沒有反應。有任何想法嗎?
你有一個崩潰報告,告訴你,這是由於內存壓力?併爲這個愚蠢的問題表示歉意,但這個信息亭肯定會在一天之內收取費用。 – davbryn
不幸的是我沒有,因爲它發生在位置上。我無法複製它,因爲視頻正在通過輔助屏幕,如果我連接了該屏幕,則無法將設備連接到Xcode。儀器在模擬器上運行,儘管它沒有崩潰,但是當我在14小時後嘗試使用它時,該應用程序非常反應遲鈍。 – Jan
您的應用程序是否監視可用磁盤空間? – bneely