Results 1 to 37 of 37

Thread: How can I listen to a sound/music file in VB?

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    287

    Re: How can I listen to a sound/music file in VB?

    Quote Originally Posted by schoolbusdriver
    Did you try the project in the zip file "Sounds.zip" I attached to post 23 ? Did it work OK ?
    Hi, it is nice to see you online. I tried both. But coud not get the sound. I can hear just a sound like some error beep sound.

    Margaret.

  2. #2
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,236

    Re: How can I listen to a sound/music file in VB?

    Quote Originally Posted by Margaret
    But coud not get the sound. I can hear just a sound like some error beep sound.

    Margaret.
    I'll say this a third time Margaret. I can't hear any sounds when I use PlaySound API you have to compile the exe first.

    Does your computer play sounds anyway through Windows Media Player?

    You can check if you comp can play anything with the waveOutGetNumDevs API.
    VB Code:
    1. Private Declare Function waveOutGetNumDevs Lib "winmm.dll" () As Long
    2.  
    3. Private Sub Form_Load()
    4.  
    5. Dim rtn As Long
    6.  
    7. rtn = waveOutGetNumDevs()
    8.  
    9. If rtn = 0 Then
    10.     MsgBox "Your system cannot play Sound Files.", 16, "SoundCard Check"
    11. End If
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  3. #3
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: How can I listen to a sound/music file in VB?

    I've had this problem before with playing sounds from resource files. I would hear a beep until I compiled, ran the EXE, and then ran the project again from the IDE.

    But I'm guessing you probably already tried this...

    Edit: Just saw Keith's post.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    287

    Re: How can I listen to a sound/music file in VB?

    Quote Originally Posted by DigiRev
    I've had this problem before with playing sounds from resource files. I would hear a beep until I compiled, ran the EXE, and then ran the project again from the IDE.

    But I'm guessing you probably already tried this...

    Edit: Just saw Keith's post.
    Yes, I am also having the same problem. My computer plays sounds very well. So, the sound card is ok. Any other possible way to play audio files which are stored in my project folder.

    Hope to get some help.

    Margaret.

  5. #5
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: How can I listen to a sound/music file in VB?

    I've put together a little project that uses several variations of the PlaySound APIs. Unzip both files into the same folder and run the project in the IDE, then try compiling it and running the executable. Do any of them work, and if so, which ?
    Attached Files Attached Files

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 2005
    Posts
    287

    Re: How can I listen to a sound/music file in VB?

    Quote Originally Posted by schoolbusdriver
    I've put together a little project that uses several variations of the PlaySound APIs. Unzip both files into the same folder and run the project in the IDE, then try compiling it and running the executable. Do any of them work, and if so, which ?
    Hi,

    No, everytime I play either there is just a beep sound or system hangs.

    Regards,

    Margaret.

  7. #7
    Fanatic Member schoolbusdriver's Avatar
    Join Date
    Jan 2006
    Location
    O'er yonder
    Posts
    1,020

    Re: How can I listen to a sound/music file in VB?

    Well, that answers one question - it looks like your PC has similar problems as DigiRev's and Keithuk's when trying to use the PlaySound APIs. I haven't got any idea what causes it. There are the alternatives such as those mentioned in earlier posts. Also, in my signature - VB - mciSendString - audio/video playback / video splashscreen etc from resource file. Although this is mainly intended as a splashscreen, it can easily be adapted to simply play sounds from a resource file - the form doesn't have to be visible.

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