This tutorial will show you how to create a function that will allow you to easily play sounds simultaneously at anytime during your applications runtime. Just follow the instructions given below.
Playing Simultaneous Sounds
Because this method uses the .Net Window's Media Player library your will have to add a references to Windows Media Play in your project. This is quite a simple task, just:
Click Projects and select add Reference. Then select the COM tab and find Windows Media Play, select it and press OK.
Also add this code above your namespace:
using WMPLib;
With all the proper references you can now construct your sounds playing method. Create a void called PlayFile with two parameters, one for the File Path and the other for the volume. Use this code to make the function:
public void PlayFile(String FilePath, int Volume)
{
WindowsMediaPlayer myWMP = new WindowsMediaPlayer();
myWMP.windowlessVideo = true;
myWMP.uiMode = "none";
myWMP.URL = FilePath;
myWMP.settings.volume = Volume;
myWMP.controls.play();
}
Conclusion
To play two files or more during the same time, or simultaneously, simply call the PlayFile method and supply the path to your desired file and the volume level, 1 through 100, you wish to play it at. Here is an example usage of the PlayFile function:
PlayFile("C:\\My Music\\Rock.wav", 100);
PlayFile("C:\\My Music\\Jazz.wav", 50);
This example will play the Rock.wav file at the same time as the Jazz.wav file but at double the volume. The PlayFile method supports all major music and sound file formats such as .mp3, .wav, .ect.
Published by James Cloud
I like to program and do basically anything that has to do with technology and computers. View profile
- The Sound Arts Program at Ex'pression College for Digital ArtsEx'pression College for Digital Arts is a technical college which offers 3 different Bachelor's degrees. One of the programs is called "Sound Arts" and offers education in sound engineering.
Live-Action Role Playing: The 'Sport' You've Never Heard OfLive-Action Role-Playing is a great way to socialize and get exercise. It enhances the creative drive and imagination.- Playing Third Base at the Blackjack TableAdopt a basic strategy since there are differences between playing blackjack on the superhighway and at the brick-and-mortar casinos.
- Effects of Unmanaged Video Game Playing TimeTo a lot of video gamers, playing is already an integral part of daily life. But what if the playing time is already uncontrollable? What could be its consequences?
- Role Playing Games and Their Evolution from the Paper and Pencil DaysA short history of role playing games and its evolution from a pencil and paper game into the MMORPG's of today with millions of players. the economy of those games is transferring over to the real world economy and how.
- Fantasy Football: Starting Up and Playing
- How to Win at Craps by Playing the Field
- Top Tips on How to Avoid Playing Favorites with Your Kids
- Gambling - What to Expect Your First Time Playing Blackjack
- Playing to Learn Through the Ages
- Ladies Guide to Sexy Role-Playing Costumes - for Less Than $20!
- VibroAcoustic Therapy: A Sound Idea at the Wellness Center in St. Louis



