Author Topic: SetPosition at near the end of stream  (Read 508 times)

Marcus Reinhart

  • Posts: 14
SetPosition at near the end of stream
« on: 27 Sep '18 - 19:27 »

i get an BASS_ERROR_POSITION error if the StartNext CuePoint near the end of a stream. I think it is because the stream is not download to that point.
How can i set the position in this case?

Code: [Select]
int handle = BassOpus.BASS_OPUS_StreamCreateURL(AudioObject.BreakUrl, 0, BASSFlag.BASS_STREAM_AUTOFREE, null, IntPtr.Zero);

long startOffset = Bass.BASS_ChannelSeconds2Bytes(handle, AudioObject.StartNextMs / 1000);

bool result = Bass.BASS_ChannelSetPosition(handle, startOffset, BASSMode.BASS_POS_BYTE);

I hav found the parameter. With this code it works fine.
Code: [Select]
bool result = Bass.BASS_ChannelSetPosition(handle, startOffset, BASSMode.BASS_POS_BYTE | BASSMode.BASS_POS_DECODETO);
« Last Edit: 28 Sep '18 - 09:29 by Marcus Reinhart »

Ian @ un4seen

  • Administrator
  • Posts: 21791
Re: SetPosition at near the end of stream
« Reply #1 on: 28 Sep '18 - 15:14 »
It is indeed currently not possible to seek to a position that has not been downloaded yet. You can check the download progress with BASS_StreamGetFilePosition (BASS_FILEPOS_DOWNLOAD).

The BASS_POS_DECODETO flag will cause BASS_ChannelSetPosition to decode the file up to the requested position (instead of seeking) but will still stop short if the download has not reached the position. You can use BASS_ChannelGetPosition afterwards to check how far it got.