Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 19th, 2003, 02:41 AM
Registered User
Join Date: Jun 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to aldwincusi
Default How do i play midi or wav files in VB.Net?

Can anyone give me a sample code on how to play midi or wav files in VB.Net

Old June 21st, 2003, 09:13 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts

Just reference the Media Player objects and use them to play the audio.

Hal Levy
NOT a Wiley/Wrox Employee- Got a job for me?
Old June 23rd, 2003, 02:01 PM
Authorized User
Join Date: Jun 2003
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts

Here is a sub that I use:

 ' API Declaration
    Declare Auto Function sndPlaySound Lib "WINMM.DLL" (ByVal FileName As String, ByVal Options As Int32) As Int32

    ' For Info
    ' API Call Flags for sndPlaySound
    Const SND_SYNC = &H0 'synchronize playback - 'locks' app until sound finished
    Const SND_ASYNC = &H1 ' played async - app continues while sound playing
    Const SND_NODEFAULT = &H2 ' No default sound played if file not found
    Const SND_LOOP = &H8 ' 'loop the wave
    Const SND_NOSTOP = &H10 'don't stop current sound if one playing
    Const SND_NOWAIT = &H2000 'Do not wait if the sound driver is busy.
    Const SND_ALIAS = &H10000 ' Play a Windows sound (such as SystemStart, Asterisk, etc.).

    Public Sub PlayAWave(ByVal Soundfile As String, Optional ByVal MaxLoops As Integer = 1)
        ' Play a wav file one or more times, as required
        Dim i As Integer
        For i = 1 To MaxLoops
            ' Play Async - ie. Don't lock up the application
            sndPlaySound(Soundfile, SND_ASYNC And SND_NOSTOP)

    End Sub
Old April 11th, 2005, 03:55 AM
Registered User
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

How do you play a mp3 file?
particularly for shadowpug

Similar Threads
Thread Thread Starter Forum Replies Last Post
Play .wav file mvenkatesan C# 2005 3 October 22nd, 2007 07:28 AM
wav file play mvenkatesan C# 2005 1 October 17th, 2007 04:01 AM
MIDI to .WAV BrianWren Other Programming Languages 0 September 1st, 2006 02:07 PM
MIDI to .WAV BrianWren VB How-To 0 September 1st, 2006 02:06 PM
How do I play a .wav file from Resources? furjaw Visual Basic 2005 Basics 0 May 27th, 2006 11:07 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.