Quick Search for:  in language:    
Play,background,music,your,application,Also,s
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Visual Basic Stats

 Code: 3,290,928. lines
 Jobs: 207. postings

 How to support the site

 
Sponsored by:

 
You are in:
 

Does your code think in ink?
Login





Latest Code Ticker for Visual Basic.
Control By Browser
By Priyan R on 12/30


Stealth Exchange SFX
By dvchaos on 12/30


Click here to see a screenshot of this code!Mini Tetris
By Code Toad on 12/30

(Screen Shot)

Click here to see a screenshot of this code!NTMessager Network Message Utility
By B.Cem HANER on 12/30

(Screen Shot)

Math-Game
By Angelica Courtin on 12/30


Click here to see a screenshot of this code!Encryptor Xor Version 3
By DISTS on 12/30

(Screen Shot)

Click here to see a screenshot of this code!Stretch Image Two Times !! (Using GetPixel and SetPixel)
By Skinny Ugly Guy on 12/30

(Screen Shot)

Simple FileFind Class Object
By David Jonathan Messervey on 12/29


Font Rotator Module
By Lyox Soft on 12/29


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

Background Music

Print
Email
 

Submitted on: 11/20/2003 8:43:57 PM
By: Mensrea / Spyder32  
Level: Beginner
User Rating: Unrated
Compatibility:VB 5.0, VB 6.0

Users have accessed this code 955 times.
 

(About the author)
 
     Play background music on your application. Also shows how to use clickable "Play" and "Stop" commands. All basic and easy to use sound commands.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

'**************************************
' Name: Background Music
' Description:Play background music on y
'     our application. Also shows how to use c
'     lickable "Play" and "Stop" commands. All
'     basic and easy to use sound commands.
' By: Mensrea / Spyder32
'
' Inputs:'Add a module to your project. 
'     Then add this line of code to it.

Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
    'That's it for the module. Name is irrel
    '     evant, originally I left mine as "Module
    '     1".
'
'This code is copyrighted and has' limited warranties.Please see http://w
'     ww.Planet-Source-Code.com/vb/scripts/Sho
'     wCode.asp?txtCodeId=50023&lngWId;=1'for details.'**************************************

'For to long I searched for a simple bac
'     kground music tag line. Or, for a way to

'     do "Play" and "Stop" functions, that I c
    '     ould use on Form_Load.
    'This is not award winning, it's just he
    '     re to help those in need. Simple and dir
    '     ectly to the point. I hope this helps, f
    '     eel free to e-mail me if needed.
    'To make your music (midi file) begin at
    '     startup, simple add this to Form_Load.

Private Sub Form_Load()

Temp = mciSendString("play " & "NameOfMidiHere.mid", 0&, 0, 0) End Sub
'Note: You must use an "Unload". Otherwi ' se, the music continues when the applica ' tion is closed. Which could be used to t ' he benefit of a prank or annoyance. lol. ' .. To do that just add this line: Private Sub Form_Unload(Cancel As Integer)
Temp = mciSendString("stop " & "NameOfMidiHere.mid", 0&, 0, 0) End Sub
'To make a "Play" button (I used a label ' , use what you wish): Private Sub lblMusicOn_Click()
Temp = mciSendString("play " & "NameOfMidiHere.Mid", 0&, 0, 0) End Sub
'Now for the "Stop" button. Private Sub lblMusicOff_Click()
Temp = mciSendString("close " & "NameOfMidiHere.Mid", 0&, 0, 0) End Sub
'I understand there are probably better ' and more sufficient ways to do this. I'm ' sure the critics will point that out. Th ' is is just one method, and it works. For ' a beginner, that's what matters most of ' the time. I hope this helps someone...

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
11/20/2003 9:04:13 PM:Mensrea / Spyder32
Sorry about the commenting structure.  
I submitted this three times, and 
called it quits.  I'm afraid I don't 
understand how the commenting syntax 
works. lol
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Visual Basic Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.