StreamingKit icon indicating copy to clipboard operation
StreamingKit copied to clipboard

seekToTime seeks to wrong time in song

Open jamesfzhang opened this issue 9 years ago • 4 comments
trafficstars

I'm noticing a problem where my seek function plays the song at the wrong time.

@objc func seek(time: Double) {
    dispatch_async(self.methodQueue()) {
        if (self.player != nil && self.currentTrack != nil) {
            self.player.seekToTime(time)
            self.setNowPlayingInfo()
        }
    }
}

For example, time is set to 90.0, but the song starts playing at the 94th second. I'm comparing with the same song in iTunes. I took out dispatch_async and the same problem still occurs.

Anyone else experiencing this?

jamesfzhang avatar Jan 05 '16 19:01 jamesfzhang

StreamingKit estimates the offset for the HTTP RANGE request when seeking based on the average bitrate of the file so far. If you have a VBR encoded file, this can be a bit inaccurate...

tumtumtum avatar Jan 05 '16 20:01 tumtumtum

@tumtumtum What if the file is local?

jamesfzhang avatar Jan 05 '16 21:01 jamesfzhang

@jamesfzhang I did experience the same thing with streamed files. Here's the fix: https://github.com/tumtumtum/StreamingKit/pull/329

But I have no issues with local files.

derpoliuk avatar Mar 29 '17 17:03 derpoliuk

same issue. seek to wrong right time in song

veila avatar Feb 05 '18 09:02 veila