I have an application that is running on a Kiosk, open all day looping videos. Eventually, after around 1 day, the application freezes.
Here is an Instruments session after 14 hours of running:
I'm not very familiar with Instruments yet, and although the Live Bytes stay consistent and are low, the other values do seem like very high. But again, I'm not sure if that's normal or not.
This is how I create the video player:
- (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"];
}
Here is the playVideo method:
- (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];
}
And here the notification listener for when the video finishes:
- (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"];
}
}
EDIT: At first my client told me it crashed, but it looks like it actually freezes, the video stops playing and the app is unresponsive. Any ideas?