播放实时视频时,SeekToTime方法在iOS 9中无效。即使在搜索之后,视频也不会从寻找位置播放。 在以前的iOS版本中,它工作正常。 以下是代码......
- (无效)loadVideo {
cam = ipcam('http://10.5.5.9:8080/live/amba.m3u8', 'admin', 'myfoscam')
preview(cam) %dislay the images
}
- (IBAction为)SeekToTimeInVideo:(ID)发送方{ [玩家暂停];
[player pause];
player = nil;
asset = [AVAsset assetWithURL:[NSURL URLWithString:@"http://playertest.longtailvideo.com/adaptive/wowzaid3/playlist.m3u8"]];
playerItem = [AVPlayerItem playerItemWithAsset:asset];
player = [AVPlayer playerWithPlayerItem:playerItem];
AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:player];
playerLayer.frame = CGRectMake(20, 0, 600, 400);
[self.view.layer addSublayer:playerLayer];
[player play];
[self addPlayerTimeObserver];
}
任何想法?这是iOS 9中的错误。
答案 0 :(得分:1)
刚刚遇到这个问题。我看到的情况是,当你拨打-[AVPlayer seekToTime:]
时AVPlayer是否暂停,玩家会跳到最近的HLS段的末尾。
我的解决方案是在调用[player play]
之前调用-[AVPlayer seekToTime:]
...所以你会有这个:
[self.player play]
[self.player seekToTime:CMTimeMakeWithSeconds(10.0, 25.0) toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero completionHandler:^(BOOL finished)
{
[player play];
}];