Results 1 to 7 of 7
  1. #1
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Sounds (VB 6.0 / W98)

    How do you code sounds (wmv or oher sound files) into a VB application?

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Sounds (VB 6.0 / W98)

    Looky here. And what do we see coming down the lane
    with the basket full of goodies: It's the Windows API again!
    Let's see what she's got in there for playing wav files:

    Put this in the General Declarations section of code module:

    Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long

    And call it from a sub like this:

    Private Sub PlayWavFile()
    Const SND_ASYNC=&H1
    Const SND_FILENAME = &H20000
    PlaySound "fullpathtoyoursoundfile.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC
    End Sub

    Admittely, "sounds" and audio have progresses way beyond simple wav files. If you want to play "media" files like mp3, ra and all the others, you'll need to use ShellExecute (another dandy API function) on a command-line utility garnered off the net. Goggle for "VB play media files" or something similar.

    Get the API-Guide for more info on API function calls.http://www.allapi.net
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  3. #3
    Silver Lounger
    Join Date
    Mar 2001
    Location
    Springfield, Ohio, USA
    Posts
    2,136
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Sounds (VB 6.0 / W98)

    Chuck, you can also add the Microsoft Multimedia Control to your project. It's very nice: you can make it invisible and use it with just code to play sounds or made it visible and let the user play around. After you have added it to your project, press F1 while it is still selected to view the help file and the sample code. It has all that you need.

    If you are missing speakers, there is also an API call to Beep that specifies the pitch and duration. See VBapi Beep Info. HTH --Sam
    <font face="Comic Sans MS">Sam Barrett, CACI </font face=comic>
    <small>And the things that you have heard... commit these to faithful men who will be able to teach others also. 2 Timothy 2:2</small>

  4. #4
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Sounds (VB 6.0 / W98)

    Thanks Kevin,

    I got it to work just fine.

  5. #5
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Sounds (VB 6.0 / W98)

    Hi Sammy,

    So where do I find Microsoft Multimedia Control and how do I add it to my project?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Sounds (VB 6.0 / W98)

    Right click the Toolbox.
    Select Components...
    Scroll the list until you see Microsoft Multimedia Control 6.0.
    Check the box to the left of it.
    Click OK.
    Now you have a new item in your Toolbox.
    Select this item and put it on your form.
    You can set the properties of this control in the standard VB6 property window, or in the customized property pages:
    Right click the multimedia control.
    Select Properties.
    You will see the customized properties for the multimedia control.

    If you have installed MSDN, you should be able to get help on this control.

  7. #7
    Bronze Lounger
    Join Date
    Feb 2001
    Location
    Escondido, California, USA
    Posts
    1,458
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Sounds (VB 6.0 / W98)

    Thanks Hans,

    I added the control, and now I will go off and fiddle with it. <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

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