Playing CDs (1 Viewer)

kirkm

Registered User.
Local time
Tomorrow, 03:29
Joined
Oct 30, 2008
Messages
1,257
Does anyone have code to play a track on a CD?
I have some old code which uses "mciSendString". This used to work ok but now is selective, it'll play some disks but not others. I've tried stepping through but nothing is obvious, no errors or problems. Some disks just won't play. So perhaps I could replace it with something more reliable ?
 

Gasman

Enthusiastic Amateur
Local time
Today, 14:29
Joined
Sep 21, 2011
Messages
14,053
Search here. One member created a playlist DB, I seem to recall.?
 

kirkm

Registered User.
Local time
Tomorrow, 03:29
Joined
Oct 30, 2008
Messages
1,257
Haven't found it. Did find a few things via Google that also ref mciSendString. Is this the only method known ?
 

kirkm

Registered User.
Local time
Tomorrow, 03:29
Joined
Oct 30, 2008
Messages
1,257
I would like to understand how to use/debug mciSendString to fix the issue (as described in msg #1).
I've spent a few days Googling but haven't found much and have added to the mystery as some things found are for playing mp3's whereas mine are tracks from a CD (CDDA).
May I could send a breakdown of the code I have and maybe someone will be able to assist.

Access plays the track selected in a datasheet Form

Code:
Private Sub cboTTitle_DblClick(Cancel As Integer)

    Dim Msg, theTrack
    Cancel = True
    theTrack = Val(Me![TTrack])

    If theTrack <= NumberOfTracksOnThisDisk() Then
        fReadyDevice
        fSeekCDtoX (theTrack)
end if

Code:
Function fReadyDevice()
    fUnloadAll
    fSetCDPlayerReady
    SetFormat_tmsf
End Function

Function fUnloadAll()
Dim lngRet
 lngRet = mciSendString("close all", 0, 0, 0)
 fCheckForError lngRet
End Function
Function fSetCDPlayerReady()
Dim theCommand$
theCommand$ = "open " & gChosenDrive$ & " type cdaudio alias cd wait shareable" 'gChosenDrive is a global variable containing the drive letter of the CDROM e.g. "K:\" and this always is correct.

 fSetCDPlayerReady = mciSendString(theCommand$, 0, 0, 0)
End Function
Function SetFormat_tmsf()
 SetFormat_tmsf = mciSendString("set cd time format tmsf wait", 0, 0, 0)
End Function

Function fSeekCDtoX(Track%)
    fStopPlay
    SetTrack Track%
    fStartPlay  '<<<<<<<<<<<<<<<<<<
End Function

Function fStopPlay()
    mciSendString "stop cd wait", 0, 0, 0
End Function
Function SetTrack(Track%)
    mciSendString "seek cd to " & Str(Track), 0, 0, 0
End Function
Function fStartPlay()
    mciSendString "play cd", 0, 0, 0
End Function

All code executes without any errors. Mostly the track plays but sometimes nothing happens. This is repeatable. I can swap disks, find the new disk in Access and observe Disk1 playing and Disk2 failing. When a disk fails, any and all tracks on it fail.
 

Users who are viewing this thread

Top Bottom