是否可以快退/快退 AVPlayer 流? 我可以正常快进,但不能快退。
有什么帮助吗?
最佳答案
当您初始化 AVAsset 时,您指定一个选项字典,其中一个选项(实际上是我所知道的唯一选项)是 AVURLAssetPreferPreciseDurationAndTimingKey。默认为“否”。您想这样进行初始化:
AVURLAsset* asset = [[AVURLAsset alloc] initWithURL:url
options:@{AVURLAssetPreferPreciseDurationAndTimingKey: @YES}];
AVPlayerItem* playerItem = [AVPlayerItem playerItemWithAsset:asset];
self.player = [[AVPlayer alloc] initWithPlayerItem:playerItem];
您可以查询播放器项目是否可以反向播放、快退等。根据流的类型,它可能无法播放。本地磁盘上的quicktime文件当然没有问题。另请记住 AVFoundation 是异步的。这意味着您可以只调用 setter,但需要 KV 观察动态设置或使用 AVAsynchronousKeyValueLoading 协议(protocol)进行静态设置。
最后一个问题。如果您使用默认的初始化 AVCaptureSession,它会以超高质量记录,前进速度快,但后退速度慢且不稳定。即使在 iPhone 5 上也是如此。使用较低的质量设置可以获得流畅的向后播放效果。
关于iphone - AVPlayer - 快退/快退,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15167220/