ios - 使用 MPMoviePlayer 在 iOS 上 HLS 随机失败并变黑

标签 ios mpmovieplayer http-live-streaming mediaplayback

我正在 iPad、iPhone 上播放 HLS 直播。有时,突然播放器变黑,我得到以下错误

_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)}";
    }

对不起,西类牙语句子。它们的意思是无法完成操作发生未知错误

电影播放器​​在 AppDelegate didFinishLaunchingWithOptions 方法中声明如下:

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

配置播放器播放如下:

-(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;
}

有人知道会发生什么吗?谢谢。

最佳答案

我们需要更多信息,也许您的服务器在流式传输期间关闭了?您使用什么来提供流媒体服务?恩金克斯?我推荐用户 PLPlayerKit 播放直播

关于ios - 使用 MPMoviePlayer 在 iOS 上 HLS 随机失败并变黑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32997114/

相关文章:

IOS : UITableView is showing data when i tap on it

ios - 是否可以为 UICollectionView 中的每个单元格创建一个标题?

iphone - 从摄像机获取视频并使用 MPMoviePlayerController IPhone SDK 显示

ios - + [NSString stringWithContentsOfFile :] performance

ios - 类 'ProductDetailViewController' 没有初始化器

iOS - 视频不只在 iOS7 中通过 iPhone 旋转?

cocoa - 设置 MPMoviePlayerController 的 ContentURL 两次

android - 在 android 中的媒体播放器的状态栏上显示通知

ios - 为什么 HTML5 Media Source 视频不能在 IOS 上运行?

android - 如何在接到电话时暂停和播放音频流