I am streaming audio by using AVPlayer. It is working well. But Now i need to make a slider to move audio forward and backward, like typical music player. I used the function seekToTime
which works great with local audio file. But when i stream song from web url, the function stops audio when I forward slider with a large range.
My guess is that the song is being downloaded and if i move slider forward with large range then may be system has not downloaded the song data packets for that time, so it halts player.
Lets say i just hit a button to stream song but now i move slider immediately at 0 to 100th second. In this case system is not working and stops the player. Due to lack of data packets for that time.
Has anyone know how to overcome this problem or is there any other approach. I am using SWIFT for development. I am up to use any library as well if it would work in swift. This is my function:
func forward () {
timeGap = slider.value
let preferredTimeScale : Int32 = 1
let targetTime : CMTime = CMTimeMake(timeGap, preferredTimeScale)
player.seekToTime(targetTime, toleranceBefore: kCMTimeZero, toleranceAfter: kCMTimeZero)
}
Thanks in advance.