MMControl too slow

FireTail used Ask the Experts™
I'm using the Microsoft Multimedia Control V 6.0 to play wav files. Each record of an access database contains a word (or a series of words) that I want to announce. I'm using the following code:

    'Handles the Sound
Private Sub cmdAnnounce_Click()
Dim SoundBite As String
With rstStudy(4)
    If IsNull(.Fields("Sound Bite")) Then
        Exit Sub
    End If
    SoundBite = ""
    SoundBite = .Fields("Sound Bite")
End With
X = PlaySound(SoundBite, 0, SND_ASYNC Or SND_MEMORY Or SND_PURGE)
End Sub

I'm recording the "Sound Bite" to a wave file using the control, using a binary open statement to read the contents of the wav file into a string then storing that string into a 'memo' field of an Acc2000 database.  A second question, is there a better way to store the wave information directly?  The problem is that the call to PlaySound fails by crashing the application. Is there a limit on the size of the wav file? What can I change to test it? It works some of the time but when I run it in the IDE it will work 3-6 times (I haven't been able to see a pattern) then crash the app and ask me to send the notice to MS.
Also, right now I am having the user read each of the full words to record the sound bite. The database has around 800 entries right now. This database changes rarely so recording each entry is normally not a problem. However, setting it up will take quite a bit of time. Is there a way to automate this process? That isn't as important as the crash issue. Thank you for your help.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
you can save each file in a numbered sequence, or by date, or keep the end of the appsound### (numbers) to be retrieved from your database. then use a loop for each sound you want to access. with code you can see here like i found in the books online for VB.

I would also write the application to record the file to the e:\soundclips\parta\appsound### folder and store the info in the database.

Private Sub Form_Load()
    MMControl1.Notify = False
    MMControl1.Wait = True
    MMControl1.Shareable = False
    MMControl1.DeviceType = "WaveAudio"
    MMControl1.filename = "e:\sound clips\parta\appsound104.wav"

    ' Open the MCI WaveAudio device.
    MMControl1.Command = "Open"

End Sub

Private Sub Form_Unload(Cancel As Integer)
    MMControl1.Command = "Save"
    MMControl1.Command = "Close"

End Sub


another approach i haven't tried can be seen in full here:|lang_ko&ie=UTF-8

this is a clip from that site:

Listing 36.6. Adding the MAPINewMsg routine.

Public Sub MAPINewMsg()
    ' allow user to compose a message
    frmTMView.CMDialog1.Filter = "WaveForm File (*.wav)|*.wav"
    frmTMNew.MMControl1.DeviceType = "WaveAudio"
End Sub


Note that this routine (and the MAPIReadMsg routine) both just hide the main form rather than unloading it. This is necessary because the project has some values that must be shared between forms. Now add the MAPIReadMsg routine shown in Listing 36.7.


Listing 36.7. Adding the MAPIReadMsg routine.

Public Sub MAPIReadMsg(cMsgID As String)
    ' allow user to view a message
    frmTMView.CMDialog1.Filter = "WaveForm File (*.wav)|*.wav"
    frmTMRead.MMControl1.DeviceType = "WaveAudio"
End Sub


The next routine is the largest one in the module. The MAPISendMsg routine is the one that builds the MAPI message object and makes sure it is sent off to the recipient(s). Add the MAPISendMsg subroutine to the project and enter the code from Listing 36.8.


Listing 36.8. Adding the MAPISendMsg routine.

Public Sub MAPISendMsg(objRecipList As Object, cSubject As String, cBody As String, BcWavFile As String)
    ' construct a message and send it off
    On Error GoTo LocalErr
    Dim x As Integer
    ' build new message
    Set objMsg = objOutBox.Messages.Add
    objMsg.Type = "IPM.Note.TalkMail"
    objMsg.Subject = cSubject
    objMsg.Text = " " & cBody
    ' add wav file as attachment
    If Len(cWavFile) <> 0 Then
        Set objAttach = objMsg.Attachments.Add
        objAttach.Name = "Talk Mail.WAV" 'cWavFile
        objAttach.position = 0
        objAttach.Type = mapiFileData
        objAttach.Source = cWavFile
        objAttach.ReadFromFile cWavFile
    End If
    ' load recipient(s)
    If objRecipList Is Nothing Then
        MsgBox "No Recipients!"
        For x = 1 To objRecipList.Count
            Set objRecip = objMsg.Recipients.Add
            objRecip.Name = objRecipList.Item(x).Name
        Next x
    End If
    ' send it out quietly
    On Error Resume Next
    objMsg.Update ' update all the collections
    objMsg.Send showdialog:=False
    ' let everyone know
    MsgBox "Message Sent", vbInformation, "Talk Mail"
    Exit Sub
    MsgBox ErrMsg(Err), vbCritical, "MAPISendMsg"
End Sub


While your answer was informative it doesn't address why the appilcation crashes when I call the PlaySound routine. Also it doesn't address storing a sound file directly into an access2000 database. I am already using a key stored in the database to access the file but I would like to store the file directly into the database. All I am doing when the user click on the word to announce is simple to play the file, I don't ned to send it anywhere. Thank you for your help.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
- PAQ'd and points refunded
Please leave any comments here within the
next seven days.


Cleanup Volunteer
per recommendation

Community Support Moderator @Experts Exchange

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial