当使用playsound播放文件,一直播放(几个文件循环播放,用的是同步方式),当播放一段时间后,播放出来的声音都变成"嘟"的声音。请教是这么回事?

解决方案 »

  1.   

    你可能播放了系统默认的声音
    你的代码补贴出来,大家怎么看啊?
    'This project needs :
    '- a common dialog box, named CDbox
    '  (To add the Common Dialog Box to your tools menu, go to Project->Components (or press CTRL-T)
    '   and select Microsoft Common Dialog control)
    '-a button
    Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    Private Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Long
    Const SND_ASYNC = &H1
    Const SND_NODEFAULT = &H2
    Private Sub Command1_Click()
        'KPD-Team 1998
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        'Get the number of installed waveout devices
        ret& = waveOutGetNumDevs
        If ret& > 0 Then
            'Set the CommonDialogBox' filter
            CDBox.Filter = "Wave-files (*.wav)|*.wav|All Files (*.*)|*.*"
            'Set the CommonDialogBox' title
            CDBox.DialogTitle = "Choose your wave-file ..."
            'Show the 'Open File'-dialog
            CDBox.ShowOpen
            'Play the selected sound
            sndPlaySound CDBox.filename, SND_ASYNC Or SND_NODEFAULT
        Else
            MsgBox "No soundcard detected !"
        End If
    End Sub
    Private Sub Form_Load()
        Command1.Caption = "Load WAV"
    End Sub
      

  2.   

    我用Timer控件(100)
    sub timer1_timer()
    ''''''''''''''
    '这一段是读取数据库的代码。将wav相应的文件copy 到app.path & "\ttsdll\play_xh.wav"
    '''''''''''''
        for i=1 to play_xh
            sndplaysound(app.path & "\ttsdll\play" & i & ".wav",0)
            doevents
        next
    end sub
    刚运行时,占用内存9M,运行一个晚上,占用内存19M,会不会是这个原因???
      

  3.   

    timer裡調用DoEvents 可能導致重入的問題,因為DoEvents 會放棄控制權。可能出现“溢出堆栈空间”错误。
      

  4.   

    try::Const SND_ASYNC = &H1
    Const SND_NODEFAULT = &H2
    for i=1 to play_xh        
        sndplaysound(app.path & "\ttsdll\play" & i & ".wav",SND_ASYNC Or SND_NODEFAULT)
    next
      

  5.   

    我的程序的意思是一个文件播放完后才播放下一个所以得用&0sndplaysound(app.path & "\ttsdll\play" & i & ".wav",&0 Or SND_NODEFAULT)
    没有用,还是老样子。一个晚上后就没有声音了