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.

  1. 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.

  2. 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).

  3. Add a combo box, a list box and a command button to Form1.

  4. Set the Style property of Combo1 to 'Dropdown List'.

  5. Place the following code in the Declarations section of Form1:

    Dim objCDX As New VoltoCDX.CDX
    
  6. 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
    
  7. 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
    
    
  8. Place the following code in the Form1 Unload event procedure:

    Private Sub Form_Unload(Cancel As Integer)
        Set objCDX = Nothing
    End Sub
    
  9. Insert an audio CD in your CD drive.

  10. Connect to the internet.

  11. 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.



© Copyright 2006 VOLTO.COM