0
0

Hi

I need a routine to detrmine if the audio cd is insert, correct and ready to play.

I write a routine, executed in a timer control with 200ms of interval, there are some better methods??

Thanks

Luca

[code:bwk5gts0]Private Sub tmrCDReady_Timer()
Dim result As FMOD_RESULT

result = FMOD_System_CreateSound(system, "E:", (FMOD_HARDWARE Or FMOD_2D Or FMOD_CREATESTREAM Or FMOD_OPENONLY), cdsound)
If result = FMOD_OK Then
    varCDReady = True
    Me.lblDisplay.Caption = "Cd Ready!"
    Me.tmrCDReady.Enabled = False

    result = FMOD_Sound_GetNumSubSounds(cdsound, numtracks)
    ERRCHECK (result)
    result = FMOD_Sound_GetSubSound(cdsound, currenttrack, Sound)
    ERRCHECK (result)

    Exit Sub
End If

varCDReady = False

Select Case result
Case FMOD_ERR_CDDA_INIT
Case FMOD_ERR_CDDA_INVALID_DEVICE
Case FMOD_ERR_CDDA_NOAUDIO
Case FMOD_ERR_CDDA_NODEVICES
Case FMOD_ERR_CDDA_NODISC
    Me.lblDisplay.Caption = "Disk Not Present!"
End Select

End Sub[/code:bwk5gts0]

  • You must to post comments
0
0

you might be better off using the windows API for this..

  • You must to post comments
0
0

Try this on for size:

[code:w621qmed]Private Sub objCDTimer()
Dim strDrive As String

strDrive = "E:"

If (IsRemovableDeviceReady(strDrive) = True) Then

Dim result As FMOD_RESULT

result = FMOD_System_CreateSound(system, strDrive,(FMOD_HARDWARE Or FMOD_2D Or FMOD_CREATESTREAM Or FMOD_OPENONLY), cdsound)  
ERRCHECK (result) 

varCDReady = True 
Me.lblDisplay.Caption = "Cd Ready!" 
Me.tmrCDReady.Enabled = False 

result = FMOD_Sound_GetNumSubSounds(cdsound, numtracks) 
ERRCHECK (result) 
result = FMOD_Sound_GetSubSound(cdsound, currenttrack, Sound) 
ERRCHECK (result) 

End If
End Sub

Private Function IsRemovableDeviceReady(strDrive As String) As Boolean
‘Check if DIR returns successful or not...
On Error Resume Next
IsRemovableDeviceReady = Dir(strDrive) <> ""
End Function
[/code:w621qmed]

Some of the code is missing but I just pasted what you supplied earlier. So hopefully you have the pieces that are missing to that. This should be bit cleaner than what you’re currently using. Sure you could use API calls like jayDC said – they will work just as well. This function will just allow you to use built in functions already defined in VB.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.