help with sounds

SpiN9823
01-22-2004, 08:32 PM
to play a sound i made a class Public Class SoundClass
Declare Auto Function PlaySound Lib "winmm.dll" (ByVal Name _
As String, ByVal hmod As Integer, ByVal flags As Integer) As Integer
' name specifies the sound file when the SND_FILENAME flag is set.
' hmod specifies an executable file handle.
' hmod must be Nothing if the SND_RESOURCE flag is not set.
' flags specifies which flags are set.

' The PlaySound documentation lists all valid flags.
Public Const SND_SYNC = &H0 ' play synchronously
Public Const SND_ASYNC = &H1 ' play asynchronously
Public Const SND_FILENAME = &H20000 ' name is file name
Public Const SND_RESOURCE = &H40004 ' name is resource name or atom

Public Sub PlaySoundFile(ByVal filename As String)
' Plays a sound from filename.
PlaySound(filename, Nothing, SND_FILENAME Or SND_ASYNC)
End Sub
End Class
then i made a private sub Private Sub MenuItem38_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem38.Click
Dim SoundInst As New SoundClass
SoundInst.PlaySoundFile("C:\Documents and Settings\James\Desktop\FireHack 1.0\Files\intro.mp3")
End Sub and then it doesnt play.... any1 no whats rong?

Csharp
01-23-2004, 12:50 AM
you can't play mp3's with PlaySound , try playing a .wav file and it should run fine.

SpiN9823
01-23-2004, 02:52 PM
i converted my sound to .wav and nothing happens

Csharp
01-24-2004, 03:39 AM
you need to replace the " Nothing " with " 0 " , also you should only need to use SND_FILENAME , eg:

Public Class ClsSound
Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Integer, ByVal dwFlags As Integer) As Integer
Const SND_FILENAME As Integer = &H20000
Public Sub PlayWav(ByVal filename As String)
PlaySound(filename, 0, SND_FILENAME)
End Sub
End Class
'/// then in a sub ....
Dim sound As New ClsSound()
sound.PlayWav("C:\Program Files\MSN Messenger\online.wav")

SpiN9823
01-24-2004, 06:47 AM
that doesnt work.... ill try something else bnut thx anyway

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum