Solved

background music

Posted on 2002-03-18
9
341 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

752 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