1
votes

I am developing a Apple Tv app. Its a video app, where user selects videos from the grid and it starts playing in AVPlayerviewController, for some videos, it starts displaying the activity indicator (by default) and shows seek bar and then it starts playing. For some lengthy videos which it takes time to load, it displays a black screen which is against the UX.

I have gone through Netflix and have seen that, it displays a Activity Indicator when starts the VideoPlayer page. I even can add a activity indicator, however don't know the delegate function where, I will dismiss it.

Can anyone let me know the procedure to add/dismiss the activity indicator?

1

1 Answers

2
votes

You can add the observer to check the status of your Player Item and when its ready to play then you can remove the activity Indicator.

[playerItem addObserver:self
                      forKeyPath:kStatusKey
                         options:NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew
                         context:AVPlayerStatusObservationContext];


- (void)observeValueForKeyPath:(NSString*) path
                      ofObject:(id)object
                        change:(NSDictionary*)change
                       context:(void*)context
{
    if (context == AVPlayerStatusObservationContext)
    {
        AVPlayerStatus status = [[change objectForKey:NSKeyValueChangeNewKey] integerValue];
        if (status == AVPlayerStatusReadyToPlay) {
            // remove activity indicator and play video

        }
}
}