I'm trying to play a HLS Audio Streaming using AVPlayer. Everything works fine, but when I seek the player, the currentTime of the player goes to a wrong position.
If I want to seek to 38s, after the seek function executes, my currentTime printed inside the seek completion handler gives me 10s, e.g.. Most of the time, the player starts from a different position after seeking.
Here is the code I'm using:
let cmTime = CMTime(seconds: validTime, preferredTimescale: CMTimeScale(NSEC_PER_SEC))
self.player.seek(to: cmTime, toleranceBefore: kCMTimeZero, toleranceAfter: kCMTimeZero, completionHandler: { (finished) in
self.player.currentTime().seconds
})
I saw that AVFoundation does not work properly with VBR files, but all my files are CBR. They all have a constant bit rate of 128kb/s. I segmented my .mp3 file to some .ts files to play as streaming too.
I would like to know if anybody has a solution for this issue or any workaround that could help me with this problem.
Thank you, guys!