Play Sound

Techy Geek

Daemon Poster
Messages
1,320
Hi,
Im doing a project that needs sound, how do I make a sound file play when the form is loaded.

PLease, please help!!!

Thanks
 
well i think if you want a responce you'll have to give us more details. what kind of sound file are you trying to make/ what OS are you running/ what is it for.
 
ive got XP home and im trying to make a .wav file play on a program that is kinda like who wants to be a millionaire, for a school project. Ive managed to get the toolbar sound player linked to the sound i want to play but i don't know the command to get the thing to play, ive looked on the internet but can't find any webs sites that can give a really simple answer that i can understand
 
its in VB, PLEASE HELP, anyone..... heeeeeeeeeeeelllllllllllllllllllppppppppppp (echo goes here)
 
Well you couls use the sound editer in windows, but it it limited to to 2 minutes.

So i would suggest a google search for Sound Recorder and d/l a free version. the shareware ones

can cost anywhere from $20 bucks to $100
hundreds depending on the featutes and quality.

i fould one on the net that cost only $15 bucks & it let me record any sound coming out of my pc speaker's & turn it into a .wav/ .wma/ or .mp3 file.
 
hi Techy Geek,
dunno wut VB u r using!, but here s a piece of code for VB.NET that would help..

Code:
'Play Sound
    Private Declare Function PlaySound Lib "winmm.dll" (ByVal data() As Byte, _
      ByVal hMod As IntPtr, ByVal hwFlags As Integer) As Integer
    Private Const SND_ASYNC As Integer = &H1        'Play asynchronously
    Private Const SND_MEMORY As Integer = &H4       'Play wav in memory

    'The .wav will be stored in this byte array
    Private Shared ClickSound As Byte()

    Shared Sub New()
        'Get running assembly name
        Dim NameSpc As String = _
    Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString()
        'Look for the button click sound in the resource stream.
        Dim SoundFile As String
        Dim WavStrm As IO.Stream = _
Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream( _
NameSpc + "." + "DRIVEBY.WAV")
        'ReDim the byte array to be the size of the embedded .wav
        ReDim ClickSound(CType(WavStrm.Length, Integer))
        'Load the .wav from the stream into the byte array
        WavStrm.Read(ClickSound, 0, Int(CType(WavStrm.Length, Integer)))
    End Sub

and where u need to play the sound u need to do this:
Code:
Call PlayWav(ClickSound)

hope this would b useful...
 
its very good, but i dont really understand it, can u please guide me through, im not all that good at VB to be perfectly honest, also is that there the one where when playing the sound it stops all other processes until the sound has finished, or the one where the program can continue anyway

thanx
not so techy geek
 
Back
Top Bottom