Domino Code Fragment

Code Name*
mci Lib
Date*
10/25/1999
Source (or email address if you prefer)*
detlef.janssen-seegert@europe.eds.com
IP address:.3.15.218.254
Description*
Type*
LotusScript
Categories*
(Misc)
Implementation:
None (plug and play)
Required Client:
4.5
Server:
(none)
Limitations:
works only in 32-bit environment
Comments:
Files/Graphics attachments (if applicable): Code:
'mciLib:

Option Public


Dim RetInt As Long
Dim RetLength As Long
Dim RetHandle As Long
Dim RetString As String
Dim cdSecs As String
Type TOC
min As Long
sec As Long
frame As Long
End Type
Dim cdTOC () As TOC
Declare Function mciSendStringA Lib "winmm.dll" (Byval CMD$, Byval Ret$, Byval RETLEN&, Byval HwndBack&) As Long
Function CDEject As Long
CDEject = mciSendStringA ("set cdaudio door open", "", 0, 0)
End Function

Function CDStop As Long
RetInt = mciSendStringA ("stop cdaudio", RetString, 63, 0)
CDStop = mciSendStringA ("close cdaudio", RetString, 63, 0)
End Function
Function CDPlay As Long
CDPlay = mciSendStringA ("play cdaudio", RetString, 63, 0)
End Function


Function CDClose As Long
CDClose = mciSendStringA ("set cdaudio door close", RetString, 63, 0)
End Function
Function CDSetTimeFormat (Form%) As Long
Select Case (Form% )
Case 1 : F$ = "ms"
Case 2 : F$ = "msf"
Case 3 : F$ = "tmsf"
End Select
mciString$ = "set cdaudio time format " & F$
CDSetTimeFormat = mciSendStringA ( mciString$, RetString, 63, 0)
End Function

Function CDNumOfTracks As Integer
RetString = Space (63)
RetInt = mciSendStringA ("status cdaudio number of tracks", RetString, 63, 0)
CDNumOfTracks = Val (Retstring)
End Function


Function CDCurrentTrack As Long
RetInt = mciSendStringA ("status cdaudio current track", RetString, 63, 0)
CDCurrentTrack = Val (RetString)
End Function
Function CDTrackLen (Track%) As String
mciString$ = "status cdaudio length track " & Str (Track%)
RetInt = mciSendStringA (mciString$, RetString, 10, 0)
CDTrackLen = Retstring
End Function

Function CDLength As String
RetString = Space (63)
RetInt = mciSendStringA ("status cdaudio length ", RetString, 63, 0)
CDLength = Retstring
End Function
Function CDTrackPos (Track%) As String
mciString$ = "status cdaudio position track " & Str (Track%)
RetInt = mciSendStringA (mciString$, RetString, 10, 0)
CDTrackPos = Trim$ (Retstring)
End Function
Function CDMode As String
RetString = Space (63)
RetInt = mciSendStringA ("status cdaudio mode", RetString, 63, 0)
CDMode = RetString
End Function

Function CDIsReady As Integer
RetString = Space (63)
CDIsReady = False
RetInt = mciSendStringA ("status cdaudio ready", RetString, 63, 0)
If Retstring = "true" Then
CDIsReady = True
End If
End Function


Function CDPause As Long
CDPause = mciSendStringA ("pause cdaudio", RetString, 63, 0)
End Function
Function CDSeekTo (Track%) As Long
mciString$ = "seek cdaudio to " & Str (Track%)
CDSeekTo = mciSendStringA (mciString$, RetString, 10, 0)
End Function

Function CDToStart As Long
CDToStart = mciSendStringA ("seek cdaudio to start", RetString, 63, 0)
End Function

Function CDToEnd As Long
CDToPlay = mciSendStringA ("seek cdaudio to end", RetString, 63, 0)
End Function
Function CDPlayFrom (Track%) As Long
mciString$ = "play cdaudio from " & Str (Track%)
CDPlayFrom = mciSendStringA (mciString$, RetString, 63, 0)
End Function

Function CDPlayFromTo (Track1%, Track2%) As Long
mciString$ = "play cdaudio from " & Str (Track1%) & " to " & Str(Track2%)
CDPlayFromTo = mciSendStringA (mciString$, RetString, 63, 0)
End Function

Function CDPrevTrack As Long
ret% = CDSetTimeFormat (3)
total% = CDNumOfTracks
current% = CDCurrentTrack
prev% = current% - 1
If CDIsPlaying Then
If prev% > 0 Then
CDPrevTrack = CDPlayFrom (prev%)
Else
CDPrevTrack = CDPlayFrom (total%)
End If
Else
If prev% > 0 Then
CDPrevTrack = CDSeekTo (prev%)
Else
CDPrevTrack = CDSeekToEnd
End If
End If
End Function

Function CDNextTrack As Long
ret% = CDSetTimeFormat (3)
total% = CDNumOfTracks
current% = CDCurrentTrack
nex% = current% + 1
If CDIsPlaying Then
If nex% < total% Then
CDNextTrack = CDPlayFrom (nex%)
Else
CDNextTrack = CDPlayFrom (1)
End If
Else
If nex% < total% Then
CDNextTrack = CDSeekTo (nex%)
Else
CDNextTrack = CDSeekToStart
End If
End If
End Function
Function CDIsPlaying As Integer
RetString = Space (63)
CDIsPlaying = False
RetInt = mciSendStringA ("status cdaudio mode", RetString, 63, 0)
If Instr (Retstring, "playing") Then
CDIsPlaying = True
End If
End Function


Function CDIsSeeking As Integer
RetString = Space (63)
CDIsSeeking = False
RetInt = mciSendStringA ("status cdaudio mode", RetString, 63, 0)
If Instr (Retstring, "seeking") Then
CDIsSeeking = True
End If
End Function

Function CDIsStopped As Integer
RetString = Space (63)
CDIsStopped = False
RetInt = mciSendStringA ("status cdaudio mode", RetString, 63, 0)
If Instr (Retstring, "stopped") Then
CDIsStopped = True
End If
End Function
Function CDIsPaused As Integer
RetString = Space (63)
CDIsPaused = False
RetInt = mciSendStringA ("status cdaudio mode", RetString, 63, 0)
If Instr (Retstring, "paused") Then
CDIsPaused = True
End If
End Function

Function CDIsOpen As Integer
RetString = Space (63)
CDIsOpen = False
RetInt = mciSendStringA ("status cdaudio mode", RetString, 63, 0)
If Instr (Retstring, "open") Then
CDIsOpen = True
End If
End Function
Function CDInit As Long
CDInit = mciSendStringA ("open cdaudio", RetString, 63, 0)
End Function
Function cddbSumme (n As Long) As Long
Dim ret As Long

ret = 0
Do While (n > 0)
ret = ret + n Mod 10
n = n \ 10
Loop
cddbsumme = ret
End Function
Function cddbKey () As String
Dim offsetm As Long
Dim offsets As Long
Dim offsetf As Long
Dim off1m As Long
Dim off1s As Long
Dim lenm As Long
Dim lens As Long
Dim lenf As Long
Dim pos As Long
Dim temp As Long
Dim sum As Long
Dim disclen As Long
Dim num As Integer
Dim j As Integer
Dim k As Integer

ret = CDSetTimeFormat (2)
num = CDNumOfTracks ()
Redim cdTOC (1 To num +1)
For j = 1 To num
Posi$ = Left (CDTrackPos (j), 8)
offsetm = Val (Left (Posi$, 2))
offsets = Val (Mid (Posi$, 4, 2))
offsetf = Val (Mid (Posi$, 7, 2))
If j = 1 Then
off1m = offsetm
off1s = offsets
End If
pos = (offsetm * 60 * 75) + (offsets * 75) + offsetf
cdTOC (j).frame = pos
pos = pos \ 75
cdTOC (j).min = pos \ 60
cdTOC (j).sec = pos Mod 60
Next
sum = 0
For k = 1 To num
temp = cdTOC (k).min * 60 + cdTOC (k).sec
sum = sum + cddbSumme (temp)
Next
sum = sum Mod 255
sum = shl (sum, 24)

Posi$ = Left (CDTrackPos (num), 8)
offsetm = Val (Left (Posi$, 2))
offsets = Val (Mid (Posi$, 4, 2))
offsetf = Val (Mid (Posi$, 7, 2))
Posi$ = Left (CDTrackLen (num), 8)
lenm = Val (Left (Posi$, 2))
lens = Val (Mid (Posi$, 4, 2))
lenf = Val (Mid (Posi$, 7, 2))
disclen = (offsetm * 60 * 75) + (offsets * 75) + offsetf + (lenm * 60 * 75) + (lens * 75) + lenf
disclen = disclen \ 75
cdSecs = Str$ (disclen)
disclen = disclen - (off1m * 60 + off1s)
disclen = shl (disclen, 8)

sum = sum Or disclen Or num
cddbKey = Lcase (Hex$ (sum))
If Len (cddbKey) < 8 Then
cddbKey = "0" & cddbKey
End If

End Function
Function shl (zahl As Long, n As Integer) As Long
s1$ = Bin$ (zahl)
s2$ = "&B" & s1$ & String (n, "0")
shl = Clng (s2$)
End Function