YU No
YU No

Reputation: 99

HLS randomnly failing and going black on iOS with MPMoviePlayer

I am playing an HLS live streaming in iPad, iPhone. Sometimes, suddenly the player goes black and I get the following error

_itemFailedToPlayToEnd: {
        AVPlayerItemFailedToPlayToEndTimeErrorKey = "Error Domain=AVFoundationErrorDomain Code=-11800 \"No se ha podido completar la operaci\U00f3n\" UserInfo=0x15a50740 {NSLocalizedDescription=No se ha podido completar la operaci\U00f3n, NSUnderlyingError=0x1467e9e0 \"The operation couldn\U2019t be completed. (OSStatus error -12312.)\", NSLocalizedFailureReason=Se ha producido un error desconocido (-12312)}";
    }

Sorry for the Spanish sentences. They mean Could not complete operation and An unknown error occurred.

Movie player is declared in the AppDelegate didFinishLaunchingWithOptions method as follows:

self.videoplayer = [[MPMoviePlayerController alloc] init];
self.videoplayer.movieSourceType = MPMovieSourceTypeStreaming;

Configuring the player to play is done as follows:

-(void) configureAndPlayPlayer:(NSURL *)contentURL
{
AppDelegate * app = (AppDelegate *)[UIApplication sharedApplication].delegate;
[app.videoplayer.view removeFromSuperview];

[self.view addSubview:app.videoplayer.view];
[self videoPlayerFrame];
[app.videoplayer stop];
app.videoplayer.contentURL = contentURL;

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
    app.videoplayer.view.center = self.view.center;
    [self videoPlayerFrame];
    CGRect frame = app.videoplayer.view.frame;
    frame.origin.y = 0;
    frame.origin.x = 0;
    app.videoplayer.view.frame = frame;
}
[app.videoplayer setScalingMode:MPMovieScalingModeAspectFit];
[app.videoplayer play];

app.eventPlaying = self.eventPlaying;
app.catchupPlaying = (self.isCatchup) ? YES : NO;
}

Does anybody know what could be happening? Thank you.

Upvotes: 1

Views: 260

Answers (1)

alfreedom
alfreedom

Reputation: 441

we need some more information, maybe your server is shutting down during streaming? what are you using to serve streaming? NGINX? i recommend user PLPlayerKit to play live streaming

Upvotes: 1

Related Questions