An issue with Seeking to Unbuffered Positions in BASS Stream from URL

Started by Qais,

Qais

Hello everyone,
I'm using the BASS library "base.dll" on Windows to stream audio directly from a URL.  I've encountered an issue when attempting to seek to a position in the stream that hasn't been buffered yet. Specifically, if the stream is at the beginning and I try to seek to the middle (which hasn't been loaded), the seek operation fails.
It seems that this thing is not available, isn't it?
Thanks.

Qais

Update: I have used offset to start from another position, and it works.
Now my issue is:
get_position gives me 0 as the current time because that is the position where the file started.
For example, if I start playing a file from the 10th minute, I will get 0, which means I won't be able to go back to the beginning of the file.
get_length correctly gives me the total duration of the file.
Is there a way to make it continue from the beginning of the file and accurately track the current position?

Ian @ un4seen

Indeed, BASS doesn't currently allow seeking to a position that hasn't been downloaded yet in an internet stream, and unfortunately there isn't an easy way around that. One way to get around it would be to implement your own downloading code that reconnects to download from a new position when seeking, and using that with BASS_StreamCreateFileUser (STREAMFILE_NOBUFFER), but it won't be a simple and it might not work well with some formats (eg. those without a precise seektable).

The simplest solution is to just retry until the wanted position is available. Most internet connections are fast these days, so it shouldn't take long in most cases. Make sure you don't use the BASS_STREAM_RESTRATE flag (or BASS_STREAM_BLOCK).