wav files

can someone run me through how to add wav files to my program

Comments

  • : can someone run me through how to add wav files to my program
    :


    I am happy to say I can.

    I looked for months for good functions for playing sound and all I got was bad code using the very TopHeavy MCI control. but thanks to persistance here it is.

    Option Explicit
    Const SND_ASYNC = &H1

    Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal _
    lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

    ' Play a WAV file.
    '
    ' FileName is a string containing the full path of the file.
    ' If SyncExec is True, the sound is played synchronously
    ' Returns True if no errors occurred

    Function PlayWAV(FileName As String, Optional SyncExec As Boolean) As Boolean
    If SyncExec Then
    ' play the file synchronously
    PlayWAV = PlaySound(FileName, 0, 0)
    Else
    ' play the file asynchronously
    PlayWAV = PlaySound(FileName, 0, SND_ASYNC)
    End If
    End Function

    Private Sub Command1_Click()

    If PlayWAV("C:WindowsMediaNotify.wav", False) Then DoEvents

    End Sub

    Enjoy, Regards Jomac.



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion