Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: VB5,VB6
Expertise: Intermediate
Feb 28, 2001

Determine the total playing time of an Audio CD

The Microsoft Multimedia Control lets you easily determine the total playing time of an Audio CD: you only need to correctly initialize the control and then decipher the value returned by its Length property. Use the following code as a guideline for your routines:

Private Sub cmdDisplayTime_Click()
    Dim Value As Integer
    Dim TotalTime As String
    
    With MMControl1
        ' Initialize the Multimedia control
        .DeviceType = "CDAudio"
        .TimeFormat = 10
        .Command = "Open"
        ' seconds are held in the most significant byte
        Value = (.Length \ 256) And 255
        TotalTime = Right$("0" & CStr(Value), 2) & """"
        ' minutes are held in the least significant byte
        Value = (.Length And 255) Mod 60
        TotalTime = Right$("0" & CStr(Value), 2) & "' " & TotalTime
        Value = (.Length And 255) \ 60
        If Value > 0 Then
            ' display hour value only if necessary
            TotalTime = CStr(Value) & "h " & TotalTime
        End If
        MsgBox TotalTime
    End With
    
End Sub

Francesco Balena
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap