473,770 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

importing background music in vb6

8 New Member
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 7961
pureenhanoi
175 New Member
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
Benzerari
9 New Member
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 New Member
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.wa v". 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.wa v" without SND_LOOP parametter. The sound-card will play "nothing.wa v" (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.wa v" 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
9607
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 restarting)" when going to the other pages. Can anyone give me some insight as to how this can be done? Appreciate any help offered. TIA Peter
4
3885
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 music. The music plays okay until the viewer clicks to cause some JavaScript code to execute. When the JavaScript code runs it stops the music even though the coding is just used to resize pictures and divs on the page (viz, it is not supposed...
21
62857
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: url(graphics/header-salmoninbucket.jpg); background-repeat: no-repeat; background-color: #B6C7B6; } When you print, however, this doesn't appear.
4
2522
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), but I've got 100+ wavs that I'd like to use so I need some code that can scale. Any help would be appreciated.
0
955
by: paodzy | last post by:
how to import a sound that serve as a background music. please cite some example of codes.
0
1097
by: paodzy | last post by:
how to import a sound that serve as a background music. please cite some example of codes.
5
1188
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 tracks appear, but won't import.
2
4412
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 the native PlaySound function but the results were the same. Any ideas how to have a background music and a button sound without using DirectSound? Can you provide me some snippets?
17
12889
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 page the music stops. How can I achieve this. any ideas !!!!! Regards Muddasir Hussain
0
9618
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10101
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.