none
How do I play wav files RRS feed

Answers

  • This is a simpler method:

            Dim soundFileName As String = "C:\folder\myWAVsound.wav"
            Dim sp As New Media.SoundPlayer
            sp.SoundLocation = soundFileName
            sp.Play()

    See if it works! (I tested this in VB2010 but think it works in VB2008 too.)

    Sincerely yours,
    - bilde2910


    If a post is helpful to you or solves a problem, remember to mark it as answer, propose it as answer or vote up.
    Check out my development so far!

    • Edited by bilde2910 Thursday, August 23, 2012 6:27 PM
    • Proposed as answer by .paul. _ Thursday, August 23, 2012 10:16 PM
    • Marked as answer by Mark Liu-lxfModerator Tuesday, September 4, 2012 7:54 AM
    Thursday, August 23, 2012 6:25 PM
  • The first hit of "play wav" in the bing box is "How to: Play Sounds in Visual Basic".  Try it.

    Thursday, August 23, 2012 6:26 PM
  • Here's a much simpler method for playing a wave file

    Public Class Form1
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            My.Computer.Audio.Play("C:\Users\John\Desktop\Heartbeat.wav", AudioPlayMode.Background)
        End Sub
    
    End Class


    You've taught me everything I know but not everything you know.

    Thursday, August 23, 2012 6:49 PM

All replies

  • This is one method

    Public Class Form1
    
        Const SND_ASYNC As Integer = &H1
        Const SND_FILENAME As Integer = &H20000
        Const SND_NODEFAULT As Integer = &H2
        Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Integer, ByVal dwFlags As Integer) As Integer
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
        End Sub
    
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    
            PlaySound("C:\Users\John\Desktop\Heartbeat.wav", 0, SND_NODEFAULT Or SND_ASYNC Or SND_FILENAME)
    
        End Sub
    
    End Class


    You've taught me everything I know but not everything you know.

    Thursday, August 23, 2012 6:08 PM
  • This is a simpler method:

            Dim soundFileName As String = "C:\folder\myWAVsound.wav"
            Dim sp As New Media.SoundPlayer
            sp.SoundLocation = soundFileName
            sp.Play()

    See if it works! (I tested this in VB2010 but think it works in VB2008 too.)

    Sincerely yours,
    - bilde2910


    If a post is helpful to you or solves a problem, remember to mark it as answer, propose it as answer or vote up.
    Check out my development so far!

    • Edited by bilde2910 Thursday, August 23, 2012 6:27 PM
    • Proposed as answer by .paul. _ Thursday, August 23, 2012 10:16 PM
    • Marked as answer by Mark Liu-lxfModerator Tuesday, September 4, 2012 7:54 AM
    Thursday, August 23, 2012 6:25 PM
  • The first hit of "play wav" in the bing box is "How to: Play Sounds in Visual Basic".  Try it.

    Thursday, August 23, 2012 6:26 PM
  • Here's a much simpler method for playing a wave file

    Public Class Form1
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            My.Computer.Audio.Play("C:\Users\John\Desktop\Heartbeat.wav", AudioPlayMode.Background)
        End Sub
    
    End Class


    You've taught me everything I know but not everything you know.

    Thursday, August 23, 2012 6:49 PM