VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "CDPlay"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False

Const MultiUse = -1   'True
Const Persistable = 0   'NotPersistable
Const DataBindingBehavior = 0  'vbNone
Const DataSourceBehavior = 0   'vbNone
Const MTSTransactionMode = 0    'NotAnMTSObject

Private Declare Function mciSendCommand Lib "winmm.dll" Alias "mciSendCommandA" (ByVal wDeviceID As Long, ByVal uMessage As Long, ByVal dwParam1 As Long, ByVal dwParam2 As Long) As Long
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Sub back()
Dim i As Long
Dim RS As String
Dim cb As Long
Dim W$
Dim s As Long
RS = Space$(128)
 
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("status cdaudio current track", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
 
Track = xt$ - 1
at$ = Space$(128): ap$ = Space$(128): at$ = Space$(128)
a = mciSendString("status cdaudio position track " & Track, at$, 128, 0)
at$ = Left$(at$, InStr(at$, Chr$(0)) - 1)
 
i = mciSendString("play cdaudio from " & at$, RS, 128, cb)
 
End Sub


Sub PlayCD()
Dim i As Long
Dim RS As String
Dim cb As Long
RS = Space$(128)
i = mciSendString("stop cdaudio", RS, 128, cb)
i = mciSendString("close cdaudio", RS, 128, cb)
'If FromPosition = "0" And ToPosition = "0" Then GoTo NoPos
'If FromPosition = "0" Then GoTo NoTo
'If ToPosition = "0" Then GoTo NoFrom
'NoPos:
RS = Space$(128)
i = mciSendString("open cdaudio", RS, 128, cb)
i = mciSendString("play cdaudio", RS, 128, cb)

'NoTo:
'RS = Space$(128)
'i = mciSendString("open cdaudio", RS, 128, cb)
'i = mciSendString("play cdaudio from " & FromPosition, RS, 128, cb)

'NoFrom:
'RS = Space$(128)
'i = mciSendString("open cdaudio", RS, 128, cb)
'i = mciSendString("play cdaudio to " & ToPosition, RS, 128, cb)

End Sub
Sub ForwardCD()
Dim i As Long
Dim RS As String
Dim cb As Long
Dim W$
Dim s As Long
RS = Space$(128)
 
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("status cdaudio current track", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
 
Track = xt$ + 1
at$ = Space$(128): ap$ = Space$(128): at$ = Space$(128)
a = mciSendString("status cdaudio position track " & Track, at$, 128, 0)
at$ = Left$(at$, InStr(at$, Chr$(0)) - 1)
 
i = mciSendString("play cdaudio from " & at$, RS, 128, cb)
 
 
End Sub

Sub StopCD()
RS = Space$(128)
Dim i As Long
Dim cb As Long
i = mciSendString("stop cdaudio", RS, 128, cb)
i = mciSendString("close cdaudio", RS, 128, cb)
 
End Sub
Sub SetTimeMSF()
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("set cdaudio time format msf", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
End Sub
Sub SetTimeMS()
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("set cdaudio time format ms", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
End Sub
Function PlayFrom(FromPosition)
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("play cdaudio from " & FromPosition, xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
End Function
Function PauseCD()
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("pause cdaudio", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
End Function

Function PlayTo(ToPosition)
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("play cdaudio to " & ToPosition, xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)

End Function

Sub SetTimeTMSF()
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("set cdaudio time format tmsf", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
End Sub
Sub CloseCD()
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("close cdaudio", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr(0)) - 1)
End Sub


Sub SeekCD(ToPosition As Integer)
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("seek cdaudio to " & ToPosition, xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
End Sub
Sub SeekToEnd(ToPosition)
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("seek cdaudio to end", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
End Sub
Sub SeekToStart(ToPosition)
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("seek cdaudio to start", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
End Sub
Sub DoorOpen()
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("set cdaudio door open", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
End Sub
Sub DoorClose()
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("set cdaudio door close", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
End Sub
Sub AudioOff()
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("set cdaudio audio all off", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
End Sub
Sub AudioLeftOff()
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("set cdaudio audio left off", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
End Sub
Sub AudioLeftOn()
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("set cdaudio audio left on", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
End Sub
Sub AudioRightOff()
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("set cdaudio audio right off", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
End Sub
Sub AudioOn()
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("set cdaudio audio all on", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
End Sub
Sub AudioRightOn()
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("set cdaudio audio right on", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
End Sub








Function NumOfTracks() As Variant

    nt$ = Space$(128): np$ = Space$(128): nt$ = Space$(128)
t = mciSendString("status cdaudio number of tracks", nt$, 128, 0)
nt$ = Left$(nt$, InStr(nt$, Chr$(0)) - 1)
NumOfTracks = nt$
End Function



Function CurrentTrack() As Variant

ct$ = Space$(128): cp$ = Space$(128): lt$ = Space$(128)
l = mciSendString("status cdaudio current track ", ct$, 128, 0)
ct$ = Left$(ct$, InStr(ct$, Chr$(0)) - 1)
CurrentTrack = ct$

End Function



Function Status() As Variant
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("status cdaudio mode", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
Status = xt$
End Function



Function Length() As Variant
    xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("status cdaudio length", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
Length = xt$
End Function



Function LengthTrack(Track As Integer)
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("status cdaudio length track " & Track, xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
LengthTrack = xt$
End Function



Function MediaPresent() As Variant

    xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("status cdaudio media present", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
MediaPresent = xt$
End Function



Function Position() As Variant
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("status cdaudio position", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
Position = xt$
End Function


Function PositionTrack(Track) As Variant
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("status cdaudio position track " & Track, xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
PositionTrack = xt$
End Function



Function StartPosition() As Variant

    xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("status cdaudio start position ", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
StartPosition = xt$
End Function



Function TimeFormat() As Variant

    xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("status cdaudio time format", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
TimeFormat = xt$
End Function



Function Ready() As Variant
    Ready = m_Ready
    xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("status cdaudio ready", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr$(0)) - 1)
Ready = xt$
End Function



Function Info() As Variant
xt$ = Space$(128): xp$ = Space$(128): xt$ = Space$(128)
X = mciSendString("info cdaudio product", xt$, 128, 0)
xt$ = Left$(xt$, InStr(xt$, Chr(0)) - 1)
Info = xt$
End Function



