Outline video freezes my iOS app at some point

I have a kiosk app open all the time in the video cycle. In the end, after about 1 day, the application freezes.

Here is the Tools session after 14 hours of operation: enter image description hereenter image description hereenter image description hereenter image description here

I am still not very familiar with the tools, and although Live Bytes remain constant and low, other values ​​seem very high. But then again, I'm not sure if this is normal or not.

This is how I create a 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 is the notification listener when the video ends:

- (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 that it crashed, but it looks like it actually freezes, the video stops playing, and the application does not respond. Any ideas?

+4
2

, , , .

. , Overall Bytes # Overall . , ( ). , 1 , , 1 .

, Overall Bytes size of video * play count.

+1

AVPlayer,

, , , . , AVPlayer ?!

  • : ( nil) (, ), . - "" , ARC ...

    //release your player (taken from here: http://stackoverflow.com/questions/17831764/how-to-stop-a-video-in-avplayer)
    [self.videoPlayer Pause];
    [self.avPlayerLayer removefromsuperlayer];
    self.videoPlayer = nil;
    
    //re-init
    
  • , setupInitialContentWithBounds , addObserver , ( removeObserver - )

0

Source: https://habr.com/ru/post/1530432/


All Articles