473,395 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

importing background music in vb6

8
how to import a background music in vb6.if the form is load then the music will start to play.can you please post the code for this.please help me....
Aug 7 '07 #1
3 7933
pureenhanoi
175 100+
how to import a background music in vb6.if the form is load then the music will start to play.can you please post the code for this.please help me....
Insert following code into the form
Expand|Select|Wrap|Line Numbers
  1. Private Declare Function sndPlaySound& Lib "winmm.dll" Alias _
  2.     "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long)
  3.  Const SND_SYNC = &H0
  4.  Const SND_ASYNC = &H1
  5.  Const SND_NODEFAULT = &H2
  6.  Const SND_LOOP = &H8
  7.  Const SND_NOSTOP = &H10
  8. Private Sub Form_Load()
  9. sndPlaySound "c:\windows\media\ringin.wav", SND_ASYNC Or SND_NODEFAULT Or SND_LOOP
  10. End Sub
  11.  
Ofcourse, this API function can be play Wave Sound Files only (.wav)
Aug 7 '07 #2
Insert following code into the form
Expand|Select|Wrap|Line Numbers
  1. Private Declare Function sndPlaySound& Lib "winmm.dll" Alias _
  2.     "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long)
  3.  Const SND_SYNC = &H0
  4.  Const SND_ASYNC = &H1
  5.  Const SND_NODEFAULT = &H2
  6.  Const SND_LOOP = &H8
  7.  Const SND_NOSTOP = &H10
  8. Private Sub Form_Load()
  9. sndPlaySound "c:\windows\media\ringin.wav", SND_ASYNC Or SND_NODEFAULT Or SND_LOOP
  10. End Sub
  11.  
Ofcourse, this API function can be play Wave Sound Files only (.wav)

But, what is the code to stop music through a clicking a button in the same form i.e.

Thank you
Aug 7 '07 #3
pureenhanoi
175 100+
But, what is the code to stop music through a clicking a button in the same form i.e.

Thank you
There is another API function (i dont remember exactly, but maybe the SendMessage() function) can play wave sound file also, and it can stop the playing progess, pause the progess, as well as get the current possition of playing progess. Let me find again and tell you latter.
But if you want stop playing sound file only by sndPlaySound() Function when one button was clicked, do it manually by your-selft with no need one more functions. First, create one Wave Sound File called : "nothing.wav". This is simply the wave sound file with very short play-lenght almost silent (ex: lenght <= 1second). When you want stop playing the background sound, simply call sndPlaySound() to play "nothing.wav" without SND_LOOP parametter. The sound-card will play "nothing.wav" (instead of background music) to the end of file and automatically stop playing.
Each time you load the form, the sound-card will play the background music for loop, and each time you press the Stop button, the sound card will play the "nothing.wav" and then stop playing. Maybe, this is not the best way to stop playing, but at least it resolve your problem.
Aug 8 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Peter | last post by:
I've embedded a midi file as background sound in my "index.html" which links to other pages on the site and I want the the same background sound to play on all pages "without interruption (and...
4
by: Doug van Vianen | last post by:
Hi, I am using Visual Basic 6 to generate web pages that can be used by the members of our seniors' computer club to create e-cards that include their own pictures. I wish to include background...
21
by: tradmusic.com | last post by:
Hi, We have the following in our stylesheet, which acts as a page header: #homepageheader { left: 0px; top: 0px; right: 0px; height: 183px; background-image:...
4
by: Scott-ASC | last post by:
I'm looking for some code that will allow me to have a random wav file played every time someone refreshes my home page. I've found some that will allow 5 different wavs (and it wasn't scalable),...
0
by: paodzy | last post by:
how to import a sound that serve as a background music. please cite some example of codes.
0
by: paodzy | last post by:
how to import a sound that serve as a background music. please cite some example of codes.
5
by: =?Utf-8?B?V2FsdA==?= | last post by:
Can't import music to movie maker. The tracks show in my music. But when I try to import from my music, under the audio file extension, the folder shows empty. When I click on "all files" the...
2
by: ventsislav | last post by:
I want to have a background music to my simple app and a buton which plays another sound, but when I press the button the sound from it interrupts the background sound. I tried with SoundPlayer and...
17
by: Muddasir | last post by:
Hi everyone. How can I play music in background while user can browse through my website. Uptill now I have created a music player which plays audio tracks but as soon as users jumps to another...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.