You can start, stop, pause, and resume playing the CD Player. Calling the CDROM_IOCTL_AUDIO_PLAY and CDROM_IOCTL_AUDIO_STOP functions automatically sets or clears the CDAUDSTAT_PAUSED flag returned by the CDROM_IOCTL_GET_AUDIO_STATE function and the CDDEVSTAT_PLAYING_AUDIO flag returned by the CDROM_IOCTL_GET_DEVICE_STATUS function.
If the drive does not support audio, ERROR_UNKNOWN_COMMAND is returned. If the starting or ending addresses are outside of the track play area, ERROR_INVALID_PARAMETER is returned.
The following code example shows how to start a CD player.
if (DeviceIoControl(g_hDev,
CDROM_IOCTL_AUDIO_PLAY,
&PlayInfo,
sizeof(PlayInfo),
NULL, 0,
&RetDataLen, NULL) == FALSE)
{
return( FALSE);
}
This function either pauses or stops the CD drive. If the CD player is playing, the function pauses the CD drive and updates the starting and ending addresses for the CDROM_IOCTL_AUDIO_RESUME function. If the CD player is paused, the function resets the starting and ending addresses for the CDROM_IOCTL_AUDIO_RESUME function.
The following code example shows how to stop a CD player.
BOOL cdStop( void)
{
DWORD RetDataLen;
if( !g_DiskValid)
return( FALSE);
if (DeviceIoControl(g_hDev,
CDROM_IOCTL_AUDIO_STOP,
NULL, 0,
NULL, 0,
&RetDataLen, NULL) == FALSE)
{
return( FALSE);
}
return( TRUE);
}
The following code example shows how to resume play on a CD device a user has stopped.
BOOL cdResume( void)
{
DWORD RetDataLen;
if( !g_DiskValid)
return( FALSE);
if (DeviceIoControl(g_hDev,
CDROM_IOCTL_AUDIO_RESUME,
NULL, 0,
NULL, 0,
&RetDataLen, NULL) == FALSE)
{
return( FALSE);
}
g_Playing = 1;
return( TRUE);
}