Solved

background music

Posted on 2002-03-18
9
342 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses
Course of the Month7 days, 5 hours left to enroll

623 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