devxlogo

Determine the total playing time of an Audio CD

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

See also  Does It Make Sense to Splurge on a Laptop?
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist