linuxer
linuxer

Reputation: 533

Recover from buffering stopping MPMoviePlayer

I am not sure what code to add, so let me know what you need to see. I am using MPMoviePlayer in conjunction with Widevine. I am having an issue where the movie stops playing. I check the MoviePlaybackStates and rarely, if ever does it catch. Most of the time it just stops. I want to believe it has something to do with buffering. I am streaming the video, and widevine callbacks gives me no errors. Any ideas how I can track this down or what the issue is?

Upvotes: 0

Views: 130

Answers (1)

M. Porooshani
M. Porooshani

Reputation: 1837

You should follow loadState instead of playbackState. The way to do it is to observe MPMoviePlayerLoadStateDidChangeNotification notification, to see how's that buffering going.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loadStateChanged:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];

somewhere before initializing your player.

and

-(void)loadStateChanged:(NSNotification *)notif
{

    NSString *loadState=@"";
    switch (self.player.loadState) {
        case MPMovieLoadStateUnknown: {
            loadState=@"MPMovieLoadStateUnknown";

            break;
        }
        case MPMovieLoadStatePlayable: {
            loadState=@"MPMovieLoadStatePlayable";

            break;
        }
        case MPMovieLoadStatePlaythroughOK: {
            loadState=@"MPMovieLoadStatePlaythroughOK";

            break;
        }
        case MPMovieLoadStateStalled: {

            loadState=@"MPMovieLoadStateStalled";
            break;
        }

    }
NSLog(@"%@", loadState);

}

Upvotes: 0

Related Questions