# CCDAudio Class

The `CCDAudio` class allows to play a CD Rom using MCI.

### Constructor

Name | Description
--- | ---
Constructor | Creates an instance of the `CCDAudio` class.

### Methods

Name | Description
--- | ---
Backward | Moves to the previous track.
Close | Closes the device or file and any associated resources. MCI unloads a device when all instances of the device or all files are closed.
CloseDoor | Closes the CDRom door.
Forward | Moves to the next track.
GetAllTracksLength | Returns the total length in seconds of all the tracks.
GetAllTracksLengthString | Returns the total length of all the tracks.
GetCurrentPos | Returns the current track position in seconds.
GetCurrentPosString | Returns the current track position.
GetCurrentTrack | Returns the current track number.
GetErrorString | Retrieves a string that describes the specified MCI error code.
GetLastError | Retrieves a The last MCI error code.
GetTrackLength | Returns the length in seconds of the given track.
GetTrackLengthString | Returns the length of the given track.
GetTracksCount | Returns the count of tracks.
GetTrackStartTime | Returns the start time of the given track.
GetTrackStartTimeString | Returns the start time of the given track.
IsMediaInserted | Checks whether CD media is inserted.
IsPaused | Checks whether is in paused mode.
IsPlaying | Checks whether is in play mode.
IsReady | Checks if the device is ready.
IsSeeking | Checks whether is in seeking mode.
IsStopped | Checks whether is in stopped mode.
Open | Initializes the device.
OpenDoor | Opens the CDRom door.
Pause | Pauses playing CD Audio.
Play | Starts playing CD Audio.
PlayFrom | Starts playing CD Audio on the given track.
PlayFromTo | Starts playing CD Audio from a given track to a given track.
Stop | Stops playing CD Audio.
ToEnd | Sets the position to the end of the audio CD.
ToStart | Sets the position to the start of the audio CD.

## Constructor

Creates an instance of the `CCDAudio` class.

    CONSTRUCTOR CCDAudio

#### Usage example:

    DIM pAudio AS CCDAudio
    pAudio.Open
    pAudio.Play

## Backward

Moves to the previous track.

    FUNCTION Backward () AS BOOLEAN

#### Return value

TRUE or FALSE.

## Close

Closes the device or file and any associated resources. MCI unloads a device when all instances of the device or all files are closed.

    FUNCTION Close () AS MCIERROR

#### Return value

Returns zero if successful or an error otherwise.

## CloseDoor

Closes the CDRom door.

    FUNCTION CloseDoor () AS MCIERROR

#### Return value

Returns zero if successful or an error otherwise.

## Forward

Moves to the next track.

    FUNCTION Forward () AS BOOLEAN

#### Return value

TRUE or FALSE.

## GetAllTracksLength

Returns the total length in seconds of all the tracks.

    FUNCTION GetAllTracksLength () AS LONG

## GetAllTracksLengthString

Returns the total length of all the tracks as a string.

    FUNCTION GetAllTracksLengthString () AS CWSTR

## GetCurrentPos

Returns the current track position in seconds.

    FUNCTION GetCurrentPos () AS LONG

## GetCurrentPosString

Returns the current track position as a string.

    FUNCTION GetCurrentPosString () AS CWSTR

## GetCurrentTrack

Returns the current track number.

    FUNCTION GetCurrentTrack () AS LONG

## GetErrorString

Retrieves a string that describes the specified MCI error code.

    FUNCTION GetErrorString (BYVAL dwError AS MCIERROR = 0) AS CWSTR

Parameter | Description
--- | ---
dwError | Optional. The MCI error code. If this parameter is omitted, the last error code is used.

## GetLastError

Returns the last MCI error code.

    FUNCTION GetLastError () AS MCIERROR

## GetTrackLength

Returns the length in seconds of the given track.

    FUNCTION GetTrackLength (BYVAL nTrack AS LONG) AS LONG

Parameter | Description
--- | ---
nTrack | The track number.

## GetTrackLengthString

Returns the length of the given track as a string.

    FUNCTION GetTrackLengthString (BYVAL nTrack AS LONG) AS CWSTR

Parameter | Description
--- | ---
nTrack | The track number.

## GetTracksCount

Returns the count of tracks.

    FUNCTION GetTracksCount () AS LONG

## GetTrackStartTime

Returns the start time of the given track.

    FUNCTION GetTrackStartTime (BYVAL nTrack AS LONG) AS LONG

Parameter | Description
--- | ---
nTrack | The track number.

## GetTrackStartTimeString

Returns the start time of the given track as a string.

    FUNCTION GetTrackStartTimeString (BYVAL nTrack AS LONG) AS CWSTR

Parameter | Description
--- | ---
nTrack | The track number.

## IsMediaInserted

Checks whether CD media is inserted.

    FUNCTION IsMediaInserted () AS BOOLEAN

#### Return value

TRUE or FALSE.

## IsPaused

Checks whether is in paused mode.

    FUNCTION IsPaused () AS BOOLEAN

#### Return value

TRUE or FALSE.

## IsPlaying

Checks whether is in play mode.

    FUNCTION IsPlaying () AS BOOLEAN

#### Return value

TRUE or FALSE.

## IsReady

Checks if the device is ready.

    FUNCTION IsReady () AS BOOLEAN

#### Return value

TRUE or FALSE.

## IsSeeking

Checks whether is in seeking mode.

    FUNCTION IsSeeking () AS BOOLEAN

#### Return value

TRUE or FALSE.

## IsStopped

Checks whether is in stopped mode.

    FUNCTION IsStopped () AS BOOLEAN

#### Return value

TRUE or FALSE.

## Open

Initializes the device.

    FUNCTION Open () AS DWORD

#### Return value

Returns zero if successful or an error otherwise.

## OpenDoor

Opens the CDRom door.

    FUNCTION OpenDoor () AS MCIERROR

#### Return value

Returns zero if successful or an error otherwise.

## Pause

Pauses playing CD Audio.

    FUNCTION Pause () AS MCIERROR

#### Return value

Returns zero if successful or an error otherwise.

## Play

Starts playing CD Audio.

    FUNCTION Play () AS MCIERROR

#### Return value

Returns zero if successful or an error otherwise.

## PlayFrom

Starts playing CD Audio on the given track.

    FUNCTION PlayFrom (BYVAL nTrack AS LONG) AS MCIERROR

Parameter | Description
--- | ---
nTrack | The track number.

#### Return value

Returns zero if successful or an error otherwise.

## PlayFromTo

Starts playing CD Audio from a given track to a given track.

    FUNCTION PlayFromTo (BYVAL nStartTrack AS LONG, BYVAL nEndTrack AS LONG) AS MCIERROR

Parameter | Description
--- | ---
nStartTrack | The starting track number.
nEndTrack | The ending track number.

#### Return value

Returns zero if successful or an error otherwise.

## Stop

Stops playing CD Audio.

    FUNCTION Stop () AS MCIERROR

## ToEnd

Sets the position to the end of the audio CD.

    FUNCTION ToEnd () AS MCIERROR

## ToStart

Sets the position to the start of the audio CD.

    FUNCTION ToStart () AS MCIERROR