Solved

background music

Posted on 2002-03-18
9
340 Views
Last Modified: 2011-09-20
How to add background midi/wav files music that will run automaticlly in an application startup?(using visual basic 6)
0
Comment
Question by:kyokugenryu
  • 5
  • 3
9 Comments
 
LVL 18

Expert Comment

by:deighton
ID: 6877258
chuck on a Windows Media Player control (via components) then

Private Sub Form_Load()
MediaPlayer1.filename = "c:\program files\messenger\test.wav"
End Sub
0
 
LVL 3

Expert Comment

by:shankarkrupa
ID: 6877370
Public 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

public sub Form_Load()
'PathandName = {Your wave file path}
Comd = "Open " & PathandName & " Type WaveAudio Alias hai"

mciSendString Comd, "", 0, 0

mciSendString "play hai", "", 0, 0

end sub

That is all...If you are using a midifile, then you should use the word 'sequencer' instead of waveaudio after the Type keyword...So, it should be:

Comd = "Open " & PathandName & " Type sequencer Alias hai"

that is all....

S Krupa Shankar
0
 
LVL 3

Expert Comment

by:shankarkrupa
ID: 6877372
Public 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

public sub Form_Load()
'PathandName = {Your wave file path}
Comd = "Open " & PathandName & " Type WaveAudio Alias hai"

mciSendString Comd, "", 0, 0

mciSendString "play hai", "", 0, 0

end sub

That is all...If you are using a midifile, then you should use the word 'sequencer' instead of waveaudio after the Type keyword...So, it should be:

Comd = "Open " & PathandName & " Type sequencer Alias hai"

that is all....

S Krupa Shankar
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:shankarkrupa
ID: 6877375
I am sorry, I am sorry, I did not see the "answer" radio button checked....Very, very sorry...I did not intend to propose this as an answer, but as only a comment...Sorry..

S Krupa Shankar
0
 

Author Comment

by:kyokugenryu
ID: 6923664
sorry for slow replying.
I'm new in VB6, can anyone show me the simple way to create a blank program that will run this 123.mid file automaticaly when the program executes?
let's say the 123.mid is in c:\midi folder.TQ
0
 
LVL 3

Expert Comment

by:shankarkrupa
ID: 6926196
Okay!

Start Visual Basic.
Select Standard EXE (Just press enter after it asks you what file to create?)
Then, in the code widow, press the follwing things (press the F7 function key to go to the code window, or alternatively, Alt->view->code)

Public 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

public sub Form_Load()
mciSendString "Open c:\midi folder\123.mid Type sequencer Alias hai", "", 0, 0
mciSendString "play hai", "", 0, 0
end sub

That is all...Now press the F5 key...You can hear that...

S Krupa Shankar
0
 

Author Comment

by:kyokugenryu
ID: 6929210
I get compile error in this line:

Public 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

any mistake in this line? could you correct it?
as a reward i increase the points to this question....TQ
0
 
LVL 3

Accepted Solution

by:
shankarkrupa earned 50 total points
ID: 6929330
Maybe you are doing it in a form....

It is a rule that these api declarations should not be declared as PUBLIC inside a form.

So, just change it to private.

So, that line should be like this:

Private 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


That is all.

S Krupa Shankar
0
 

Author Comment

by:kyokugenryu
ID: 6934733
Thanks friend..
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question