Retrieves the file position/status of a stream.

QWORD BASS_StreamGetFilePosition(
    HSTREAM handle,
    DWORD mode


handleThe stream handle.
modeThe file position/status to retrieve. One of the following.
BASS_FILEPOS_ASYNCBUFThe amount of data in the asynchronous file reading buffer. This requires that the BASS_ASYNCFILE flag was used at the stream's creation.
BASS_FILEPOS_BUFFERThe amount of data in the buffer of an internet file stream or "buffered" user file stream. Unless streaming in blocks, this is the same as BASS_FILEPOS_DOWNLOAD.
BASS_FILEPOS_BUFFERINGThe percentage of buffering remaining before playback of an internet file stream or "buffered" user file stream can resume.
BASS_FILEPOS_CONNECTEDInternet file stream or "buffered" user file stream is still connected? 0 = no, 1 = yes.
BASS_FILEPOS_CURRENTPosition that is to be decoded for playback next. This will be a bit ahead of the position actually being heard due to buffering.
BASS_FILEPOS_DOWNLOADDownload progress of an internet file stream or "buffered" user file stream.
BASS_FILEPOS_ENDEnd of audio data. When streaming in blocks (the BASS_STREAM_BLOCK flag is in effect), the download buffer length is given.
BASS_FILEPOS_SIZETotal size of the file.
BASS_FILEPOS_STARTStart of audio data.
other modes may be supported by add-ons, see the documentation.

Return value

If successful, then the requested file position/status is returned, else -1 is returned. Use BASS_ErrorGetCode to get the error code.

Error codes

BASS_ERROR_HANDLEhandle is not valid.
BASS_ERROR_NOTFILEThe stream is not a file stream.
BASS_ERROR_NOTAVAILThe requested file position/status is not available.


ID3 tags (both v1 and v2) and WAVE headers, as well as any other rubbish at the start of the file, are excluded from the BASS_FILEPOS_CURRENT, BASS_FILEPOS_DOWNLOAD, and BASS_FILEPOS_END positions. The BASS_FILEPOS_START position can be added to get the actual file position.

When streaming a file from the internet or a "buffered" user file stream, the entire file is downloaded even if the audio data ends before that, in case there are tags to be read. This means that the BASS_FILEPOS_DOWNLOAD position may go beyond the BASS_FILEPOS_END position.

It is unwise to use the BASS_FILEPOS_CURRENT position for syncing purposes because it gives the position that is being decoded, not the position that is being heard. Use BASS_ChannelGetPosition and/or BASS_ChannelSetSync instead.


When an Android media codec (except AAC/ADTS) is used by a stream, only the BASS_FILEPOS_SIZE mode is supported, as the file reading will not be handled by BASS.


Get the percentage downloaded of an internet file stream, or the buffer level when streaming in blocks.
QWORD len=BASS_StreamGetFilePosition(stream, BASS_FILEPOS_END); // file/buffer length
QWORD buf=BASS_StreamGetFilePosition(stream, BASS_FILEPOS_BUFFER); // buffer level
float progress=100.0*buf/len; // percentage of buffer filled

Get the buffering progress of a stalled internet file stream.

int progress=100-BASS_StreamGetFilePosition(stream, BASS_FILEPOS_BUFFERING);

See also

BASS_ChannelGetPosition, BASS_ChannelGetLength