Results 1 to 8 of 8

Thread: how do you add music to an app and in what form?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2000
    Location
    Ca
    Posts
    93
    How do you add music to an app and in what form. .mp3? .wav?
    Timbudtwo
    I have no life, only one with computers.

    VB 6.0 Enterprise Edition
    [hr]

  2. #2
    Guest
    put this in a module


    Code:
    Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
    and add this to a command button or whatever

    Code:
    Private Sub Command1_Click()
    Dim d As Long
    Call PlaySound("c:\windows\desktop\dennis3\Genflit0.wav", d, d)
    DoEvents
    End Sub
    d is just there as a blank thing.. because I dont know what the last to arguments are for
    for some reason it kind of locks up.. it freezes the program you have to keep hitting the stop button(in the Vb IDE)
    I am not sure why though.

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    wav

    'Play A sound
    'Paste this code into a bas module
    '
    'API Function to play the sound
    '
    Declare Function sndPlaySound Lib "winmm" Alias _
    "sndPlaySoundA" (ByVal lpszSoundName As String, _
    ByVal uFlags As Long) As Long
    '
    ' play synchronously (default)
    Public Const SND_SYNC = &H0
    ' play asynchronously
    Public Const SND_ASYNC = &H1
    ' loop the sound until next
    Public Const SND_LOOP = &H8

    '=====================================================

    'Paste this code into the main
    'from your main program (button or load or whatever):
    'call the function using your wave file & location..replace "A:\whoosh.wav"
    '
    Call sndPlaySound(ByVal "a:\whoosh.wav", SND_ASYNC)

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4
    Guest
    Use the mciSendString to play a MIDI file.

    Code for module.
    Code:
    Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
    Put this code in a CommandButton
    Code:
    Private Sub Command1_Click()
    
       ' Open's the MIDI 
       mciSendString "open C:\Mptheme.mid type sequencer alias background", 0, 0, 0
       ' Play's the MIDI
       mciSendString "play background", 0, 0, 0
    
    End Sub
    Put this code in another CommandButton. You must press this button to stop playing the music.
    Code:
    Private Sub cmdStop_Click()
    
       ' Closes the MIDI
       mciSendString "close background", 0, 0, 0
    
    End Sub

  5. #5
    Fanatic Member mikeycorn's Avatar
    Join Date
    Jun 2000
    Location
    Aliso Viejo, CA, USA
    Posts
    526
    I put this in module1:

    Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long


    I put this in form1:

    Private Sub Command1_Click()

    ' Open's the MIDI
    mciSendString "open C:\Program Files\Pest\Hall.mid type sequencer alias background", 0, 0, 0
    ' Play's the MIDI
    mciSendString "play background", 0, 0, 0

    End Sub

    Private Sub Command2_Click()
    ' Closes the MIDI
    mciSendString "close background", 0, 0, 0

    End Sub


    My forms and buttons are set, "Winmm.dll" is in my system files, the file "hall.mid" is where it should be and my midi is not muted on my sound card's mixer.

    What the hell am I doing wrong?


    ~ mikeycorn

    With over 45,000 Questions in the User Submitted Database, it's the Most Popular Quiz Creation Software on the Net:

    PEST - The Personal Exam Self-Tester

  6. #6
    Lively Member
    Join Date
    Jan 2000
    Posts
    95
    [b]Mikeycorn. That is EXCATLY the same thing that Megatron posted!!! You just changed the Filename!

    Before you post, read the replies that were mentioned earlier! Especially if it's almost 1 month old!!


  7. #7
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    mikeycorn

    mikeycorn

    Re: What the hell am I doing wrong...

    Code:
    'don't know about Meg's code 
    'but my code works fine
    ' 
    'API Function to play the sound 
    ' 
    Public Declare Function sndPlaySound Lib "winmm" Alias _ 
    "sndPlaySoundA" (ByVal lpszSoundName As String, _ 
    ByVal uFlags As Long) As Long 
    ' 
    ' play synchronously (default) 
    Public Const SND_SYNC = &H0 
    ' play asynchronously 
    Public Const SND_ASYNC = &H1 
    ' loop the sound until next 
    Public Const SND_LOOP = &H8 
    
    Private Sub Command1_Click() 
    
    Call sndPlaySound(ByVal "c:\yourfolder\yourfile.mid", SND_ASYNC) 
    
    End Sub 
    
    Private Sub Command2_Click() 
    Call sndPlaySound(0,0)  
    End Sub

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  8. #8
    Fanatic Member mikeycorn's Avatar
    Join Date
    Jun 2000
    Location
    Aliso Viejo, CA, USA
    Posts
    526
    Hey Zej,

    I wasn't replying to the first post, I had cut and pasted Megatron's code and it wasn't working for me, okay? It might have been redundant to post the code again with nothing changed but the file name, but I was perplexed as to why it wouldn't work for me.

    ~ mikeycorn

    With over 45,000 Questions in the User Submitted Database, it's the Most Popular Quiz Creation Software on the Net:

    PEST - The Personal Exam Self-Tester

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