|
-
Jun 18th, 2000, 05:04 AM
#1
Thread Starter
Lively Member
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]
-
Jun 18th, 2000, 06:26 AM
#2
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.
-
Jun 18th, 2000, 06:34 AM
#3
_______
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
-
Jun 18th, 2000, 07:18 AM
#4
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
-
Jul 16th, 2000, 07:44 PM
#5
Fanatic Member
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?
-
Jul 17th, 2000, 08:48 AM
#6
Lively Member
[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!!
-
Jul 17th, 2000, 09:53 AM
#7
_______
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
-
Jul 17th, 2000, 02:58 PM
#8
Fanatic Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|