Hello. I have created a CD player using mciSendStrings, but I am having trouble getting the current track. For some reason, the code below is always returning the current track as "1":
VB Code:
Public getCurrentTrack As Integer = Nothing Sub CDplay() Try Dim totalTime As String = Space(128) mciSendString("close " & TheFile, CStr(0), 0, 0) TheFile = Chr(34) & Trim(MP3File) & Chr(34) mciSendString("open " & TheFile, CStr(0), 0, 0) mciSendString("Set " & TheFile & " time format TMSF", 0, 0, 0) mciSendString("Status " & TheFile & " current track", totalTime, 128, 0) getCurrentTrack = Val(totalTime) If getNumberTracks() = track Then mciSendString("Play " & TheFile & " from " & getCurrentTrack, 0, 0, 0) Else mciSendString("Play " & TheFile & " from " & getCurrentTrack & " to " & getCurrentTrack + 1, 0, 0, 0) End If Catch exc As Exception MessageBox.Show(exc.Message, "Error!", MessageBoxButtons.OK) End Try End Sub




Reply With Quote