Thu*_*ham 7 xcode ios avplayer avplayeritem
我用多个视频实现了视频播放AVPlayer.当我播放下一个视频时,有时会显示以下错误消息:
Error Domain = AVFoundationErrorDomain Code = -11850"Operation Stopped"UserInfo = 0x1744796c0 {NSUnderlyingError = 0x170055db0"操作无法完成.(OSStatus error -12939.)",NSLocalizedFailureReason =服务器配置不正确.,NSLocalizedDescription = Operation停止}
我发现11850错误是:AVErrorServerIncorrectlyConfigured这意味着
发送媒体资源的HTTP服务器未按预期配置.这可能意味着服务器不支持字节范围请求.
请帮我这个案例,这是我播放视频的代码
- (void)playVideoWithUrl:(NSString *) videoUrl
{
if (player != nil) {
[player.currentItem removeObserver:self forKeyPath:@"status"];
[player.currentItem removeObserver:self forKeyPath:@"playbackLikelyToKeepUp"];
}
AVURLAsset * asset = [[AVURLAsset alloc]initWithURL:[NSURL URLWithString:videoUrl]
options:nil];
AVPlayerItem * item = [[AVPlayerItem alloc]initWithAsset:asset];
// Add KVO to detech status of loading video
[item addObserver:self
forKeyPath:@"status"
options:0
context:nil];
// Add KVO to detech when playback is loading buffer successfully
[item addObserver:self
forKeyPath:@"playbackLikelyToKeepUp"
options:0
context:nil];
// Detect when playback completed
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:[player currentItem]];
[player replaceCurrentItemWithPlayerItem:item];
[player play];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1613 次 |
| 最近记录: |