AVPlayer甚至在容差范围内也无法准确找到之前:kCMTimeZero [英] AVPlayer Seek not accurate even with toleranceBefore: kCMTimeZero
问题描述
我们有一个可以播放长mp3文件(1小时长)的应用.我们希望能够从文件中的设定点开始播放.但是,当我们执行此操作时,最多10秒是不准确的.
We have an app which plays a long mp3 file (1 hour long). We want to be able to play from set points within the file. But, when we do it, it is inaccurate by up to 10 seconds.
代码如下:
let trackStart = arrTracks![MediaPlayer.shared.currentSongNo].samples
let frameRate : Int32 = (MediaPlayer.shared.player?.currentItem?.asset.duration.timescale)!
MediaPlayer.shared.player?.seek(to: CMTimeMakeWithSeconds(Double(trackStart), frameRate),
toleranceBefore: kCMTimeZero, toleranceAfter: kCMTimeZero)
- 我们必须使用AVPlayer,因为我们需要质量更好的光谱":AVAudioTimePitchAlgorithm.
-
我们没有AVAudioPlayer的问题,但是(AFAIK)我们必须使用AVPlayer,因为我们需要质量更好的光谱":AVAudioTimePitchAlgorithm.
- We have to use AVPlayer because we need the better quality "spectral:" AVAudioTimePitchAlgorithm.
We didn't have the problem with AVAudioPlayer, but (AFAIK) we have to use AVPlayer because we need the better quality "spectral:" AVAudioTimePitchAlgorithm.
-错误是一致的-对于给定的请求位置,它始终从同一(错误)位置播放.重新启动后也是如此.
- The error is consistent - it always plays from the same (wrong) place for a given requested position. This is also true after restarting.
非常感谢您的帮助!谢谢
Any help very much appreciated! Thanks
- 我们已经尝试过
preferredTimescale: playerTimescale
- 也尝试使用
kCMTimeIndefinite
代替kCMTimeZero
- We have already tried
preferredTimescale: playerTimescale
- Also tried
kCMTimeIndefinite
instead ofkCMTimeZero
推荐答案
这是
AVURLAsset
的AVURLAssetPreferPreciseDurationAndTimingKey
的用途.请注意,这会增加加载时间.
Beware that this should increase the loading time.
这篇关于AVPlayer甚至在容差范围内也无法准确找到之前:kCMTimeZero的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- 我们已经尝试过