Results 1 to 6 of 6

Thread: playing sounds

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Location
    england
    Posts
    87

    playing sounds

    Im a new in making games.

    So please help me out.

    Here is the question:


    How do i play a sound when triggered by an event ?
    and
    How the hell do i attach a sound file into my form so that it will be inside the exe file ?


    Hmmm....do i sound like an idiot ?

    Oh by the way, can i play mp3 files ?

  2. #2
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284
    you can play a wav with this api call:

    VB Code:
    1. Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
    2. Const SND_ASYNC = &H1
    3. Const SND_NODEFAULT = &H2
    4. Const SND_FILENAME = &H20000
    5.  
    6. Private Sub Command1_Click()
    7. Dim retval As Long
    8.  
    9. retval = PlaySound("C:\anna.wav", 0, SND_FILENAME Or SND_ASYNC Or SND_NODEFAULT)
    10.  
    11. End Sub

    click here if you need more information about this call

    >Oh by the way, can i play mp3 files ?
    with this api call i think u cant, you will need a mp3 player dll or something...

    R,
    Jim.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Location
    england
    Posts
    87
    can u please explain what are these for ?
    SND_ASYNC = &H1
    SND_NODEFAULT = &H2
    SND_FILENAME = &H20000


    Thanks for the help.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Location
    england
    Posts
    87
    ooops
    didnt see the link.


    Anyone knows how to store the file in the exe file ?

  5. #5
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284
    man i think u cant.. try to make a resource file...

  6. #6
    Addicted Member Bazza81's Avatar
    Join Date
    Apr 2001
    Location
    Nottingham, UK
    Posts
    203

    Talking Yes you can

    If you use a resource file then extract the file into a byte array. Then make a temporary file to export the byte array into and there you go, a wave file for you to play. Just make sure you delete the wave file when the program terminates!
    Who needs rhetorical questions anyway?


    Bazza NET - The place you want to be!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width