BASS.NET API for the Un4seen BASS Audio LibraryBassBASS_ChannelSetPosition Method (Int32, Int64)BASS.NET API for the Un4seen BASS Audio Library
Sets the playback position in bytes of a sample, MOD music, or stream.

Namespace: Un4seen.Bass
Assembly: Bass.Net (in Bass.Net.dll) Version: 2.4.12.0
Syntax

public static bool BASS_ChannelSetPosition(
	int handle,
	long pos
)

Parameters

handle
Type: SystemInt32
The channel handle... a HCHANNEL, HSTREAM or HMUSIC.
pos
Type: SystemInt64
The position, in bytes.

Return Value

Type: Boolean
If succesful, then is returned, else is returned. Use BASS_ErrorGetCode to get the error code.
Remarks

Setting the position of a MOD music in bytes requires that the BASS_MUSIC_PRESCAN flag was used in the BASS_MusicLoad(String, Int64, Int32, BASSFlag, Int32) call. When setting the position in orders/rows, the channel's byte position (as returned by BASS_ChannelGetPosition(Int32, BASSMode)) is reset to 0. This is because it's not possible to get the byte position of an order/row position - it's possible that a position may never be played in the normal cause of events, or it may be played multiple times.

When changing the position of a MOD music, and the BASS_MUSIC_POSRESET flag is active on the channel, all notes that were playing before the position changed will be stopped. Otherwise, the notes will continue playing until they are stopped in the MOD music. When setting the position in bytes, the BPM, "speed" and "global volume" are updated to what they would normally be at the new position. Otherwise they are left as they were prior to the postion change, unless the seek position is 0 (the start), in which case they are also reset to the starting values (when using the BASS_MUSIC_POSRESET flag). When the BASS_MUSIC_POSRESETEX flag is active, the BPM, speed and global volume are reset with every seek.

When setting the position of a file stream, the position is automatically rounded down to the nearest sample. For MP3/MP2/MP1 streams, if the BASS_STREAM_PRESCAN flag was used when BASS_StreamCreateFile(String, Int64, Int64, BASSFlag) was called to create the stream, then the seeking will be accurate to the exact requested byte. Otherwise it will be an approximation, which is generally still very accurate. Note: BASS_STREAM_PRESCAN is ONLY needed for files with a VBR, files with a CBR are always accurate.

Seeking in internet file (and "buffered" user file) streams is possible once the download has reached the requested position, so long as the file is not being streamed in blocks (BASS_STREAM_BLOCK flag).

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not a valid channel.
BASS_ERROR_NOTFILEThe stream is not a file stream.
BASS_ERROR_POSITIONThe requested position is invalid, eg. beyond the end.
BASS_ERROR_NOTAVAILThe download has not yet reached the requested position.
BASS_ERROR_UNKNOWNSome other mystery problem!

Examples

Set the position of a stream channel to 10sec. and 200ms:
VB
Bass.BASS_ChannelSetPosition(stream, Bass.BASS_ChannelSeconds2Bytes(stream, 10.20))
Bass.BASS_ChannelSetPosition(stream, Bass.BASS_ChannelSeconds2Bytes(stream, 10.20));
See Also

Reference