VoltoCDX CDDB Component
Introduction
User Guide
Object Model
Technical Reference
Code Example
Download
Buy a License
Other Volto Components
|
|
This Visual Basic code example shows how to use the VoltoCDX CDDB Component to retrieve detailed track
information about an audio CD from the CDDB database service operated by freedb.org. This is one of the samples included with the VoltoCDX evaluation kit which
can be downloaded here.
- Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default.
- Choose Project References (ALT, P, N) and in the list of Available References make sure that the entry
entitled Volto CDDB Component is selected (i.e. checked).
- Add a combo box, a list box and a command button to Form1.
- Set the Style property of Combo1 to 'Dropdown List'.
- Place the following code in the Declarations section of Form1:
Dim objCDX As New VoltoCDX.CDX
- Place the following code in the Form1 Load event procedure:
Private Sub Form_Load()
'-- Show all available CD drives
For n = 1 To objCDX.Drives.Count
Combo1.AddItem objCDX.Drives(n)
Next n
Combo1.ListIndex = 0
End Sub
- Place the following code in the Command1 Click event procedure:
Private Sub Command1_Click()
' List all tracks of all matching CDs in the database
Screen.MousePointer = vbHourglass
List1.Clear
objCDX.GetData modeCD, Combo1
For Each CD In objCDX.CDs
List1.AddItem "CD Title: " & CD.Title & _
" Artist: " & CD.Artist & _
" Length: " & CD.LengthMS
For Each Track In CD.Tracks
List1.AddItem " > Track title: " & _
Track.Title & _
" Length: " & _
Track.LengthMS
Next
Next
Screen.MousePointer = vbDefault
End Sub
- Place the following code in the Form1 Unload event procedure:
Private Sub Form_Unload(Cancel As Integer)
Set objCDX = Nothing
End Sub
- Insert an audio CD in your CD drive.
- Connect to the internet.
- From the Run menu, choose Start (ALT, R, S), or press the F5 key to run the program. Select a the CD
drive letter for the drive containing your audio CD. Click the Command1 button. The results of the CDDB
database query will be displayed.
|
|