Results 1 to 16 of 16

Thread: Playing Sound In VB6 Application ? ? ?

Threaded View

  1. #1

    Thread Starter
    New Member yarick's Avatar
    Join Date
    Dec 2005
    Location
    C:\WINDOWS\Repair\Sam
    Posts
    7

    Question Playing Sound In VB6 Application ? ? ?

    Ok, I got my litl porgram done now, but at the end i realized that i need to play sound constantly all the time my program runs. I've found one way to do it by adding this script into main form:

    Private Sub form_load()
    'This script could be changed to the Command1_Click event as well or any event you want to play your sound on though i need it the whole time

    Dim i As Long
    Const SoundFileName$ = "C:\Documents and Settings\Owner\My Documents\My Music\binacard_1.wav"

    i = waveOutGetNumDevs()
    If i > 0 Then
    i& = sndPlaySound(SoundFileName$, Flags&)
    Else
    Beep
    End If

    End Sub

    And also i have to declare funct. in separate module:

    Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
    Public Declare Function waveOutGetNumDevs Lib "winmm" () As Long

    Global Const SND_SYNC = &H0 'just after the sound is ended exit function
    Global Const SND_ASYNC = &H1 'just after the beginning of the sound exit function
    Global Const SND_NODEFAULT = &H2 'if the sound cannot be found no error message
    Global Const SND_LOOP = &H8 'repeat the sound until the function is called again
    Global Const SND_NOSTOP = &H10 'if currently a sound is played the function will return without playing the selected sound

    Global Const Flags& = SND_ASYNC Or SND_NODEFAULT

    So, as the result I get that soundfile, "binacard1.wav" playing in the background whenever my program starts (it only has one main window).
    Though My Questions are:

    1. How can i include that soundfile in my .exe file? Is it possible at all?
    2. If not, Is there any way i can get my program to play it from internet? (file is ~300kb and i already uploaded it on http://yarick.animaze.net/binacard_1.wav)
    3. I also need to LOOP playing of this sound, so that it's being played the whole time until u terminate the program. Is it Possible at all, and if yes - what do i change in my script? Do i have to use another one in order to do that?



    //So the whole point is to get compact with the sound (so i only have one .exe file and nothing else and so it works the same way on any PC), and LOOP it.


    THANX FOR HELP IN ADVANCE!
    i'm not really experienced in VB6 so don't mind me if something i've asked is really simple
    Last edited by yarick; Dec 7th, 2005 at 08:32 PM. Reason: forgot somethin

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