BASS.NET API for the Un4seen BASS Audio LibraryBassCdBASS_CD_StreamSetTrack Method BASS.NET API for the Un4seen BASS Audio Library
Changes the track of a CD stream.

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

[DllImportAttribute("basscd.dll", CharSet = CharSet.Auto)]
public static bool BASS_CD_StreamSetTrack(
	int handle,
	int track
)

Parameters

handle
Type: SystemInt32
The CD stream handle.
track
Type: SystemInt32
The new track... 0 = the first track, BASS_CD_TRACK_PREGAP = 1st track pregap (not all drives support reading of the 1st track pregap).

Return Value

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

The stream's current position is set to the start of the new track.

This function is identical to using the BASS_POS_CD_TRACK 'mode' with BASS_ChannelSetPosition(Int32, Int64, BASSMode). Either can be used with a BASS_SYNC_END sync (set via BASS_ChannelSetSync(Int32, BASSSync, Int64, SYNCPROC, IntPtr)) to play one track after another.

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not valid.
BASS_ERROR_NOCDThere's no CD in the drive.
BASS_ERROR_CDTRACKtrack is invalid.
BASS_ERROR_NOTAUDIOThe track is not an audio track.

Examples

Play an entire CD without any gap between tracks:
VB
Private _mySync As SYNCPROC ' make it global, so that the GC can not collect it
...
' create CD stream
Dim stream As Integer = BassCd.BASS_CD_StreamCreate(0, track, BASSFlag.BASS_DEFAULT Or BASS_STREAM_AUTOFREE)
_mySync = New SYNCPROC(AddressOf EndSync)
Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_END Or BASSSync.BASS_SYNC_MIXTIME, 0, _mySync, IntPtr.Zero)
' start playing
Bass.BASS_ChannelPlay(stream, False)
...
Private Sub EndSync(handle As Integer, channel As Integer, data As Integer, user As IntPtr)
  ' get current track
  Dim track As Integer = Utils.LowWord32(BassCd.BASS_CD_StreamGetTrack(channel))
  ' jump to next track
  BassCd.BASS_CD_StreamSetTrack(channel, track + 1)
End Sub
private SYNCPROC _mySync;  // make it global, so that the GC can not collect it
...
// create CD stream
int stream = BassCd.BASS_CD_StreamCreate(0, track, BASSFlag.BASS_DEFAULT | BASS_STREAM_AUTOFREE);
_mySync = new SYNCPROC(EndSync);
Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_END | BASSSync.BASS_SYNC_MIXTIME, 0, _mySync, IntPtr.Zero);
// start playing
Bass.BASS_ChannelPlay(stream, false);
...
private void EndSync(int handle, int channel, int data, IntPtr user)
{
  // get current track
  int track = Utils.LowWord32(BassCd.BASS_CD_StreamGetTrack(channel));
  // jump to next track
  BassCd.BASS_CD_StreamSetTrack(channel, track + 1);
}
See Also

Reference