Add a MMControl and a Picturebox to a Form:
Code:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Sub Form_Load()
With MMControl1
.DeviceType = "CDAudio"
.FileName = "H:" 'Change this to your CDROM Drive Letter
.AutoEnable = True
.UpdateInterval = 10
.Command = "OPEN"
End With
End Sub
Private Sub MMControl1_StatusUpdate()
Dim lTime As Long
Dim bBytes(3) As Byte
Dim lPos As Long
Static lTrackLength As Long
Static lTrack As Long
If MMControl1.Mode <> mciModePlay Or lTrackLength = 0 Or lTrack <> MMControl1.Track Then
lTime = MMControl1.TrackLength
CopyMemory bBytes(0), lTime, 4
Caption = "Track: " & MMControl1.Track & " - " & Right("00" & bBytes(0), 2) & ":" & Right("00" & bBytes(1), 2)
lTrackLength = (60 * bBytes(0)) + bBytes(1)
Picture1.Cls
lTrack = MMControl1.Track
Else
lTime = MMControl1.Position - MMControl1.TrackPosition
CopyMemory bBytes(0), lTime, 4
lPos = (bBytes(0) * 60) + bBytes(1)
Picture1.Line (0, 0)-((Picture1.ScaleWidth / lTrackLength) * lPos, Picture1.ScaleHeight), vbBlue, BF
End If
End Sub