Solved

background music

Posted on 2002-03-18
9
334 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:kyokugenryu
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks friend..
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now