Running Multiple .Wav Files

how to run more than one sound at the same time

Page 1 of 1

2 Replies - 9056 Views - Last Post: 02 April 2009 - 03:02 PM Rate Topic: -----

#1 painkiller102   User is offline

  • D.I.C Regular
  • member icon

Reputation: 18
  • View blog
  • Posts: 281
  • Joined: 27-February 08

Running Multiple .Wav Files

Posted 02 April 2009 - 09:21 AM

ok, i know there is alot of different ways to use sound in c#, but i cant seem to figure out how to get more than one sound file to run at the same time IE: background music is playing and then you pick up an item and both sounds are playing. To this Point i have been using the system.media class:
	public partial class Form1 : Form
	{
		public SoundPlayer _bgMusic = new SoundPlayer("background.wav");
		public SoundPlayer _item = new SoundPlayer("item.wav");
		public Form1()
		{
			InitializeComponent();
		}

		private void Form1_Load(object sender, EventArgs e)
		{
			_bgMusic.Load();
			_item.Load();
			_bgMusic.PlayLooping();
		}

		private void button1_Click(object sender, EventArgs e)
		{
			_item.Play();
		}
	}


however this only will play one streaming sound at once, so it wont do what i need it to do. I also tried making a separate thread hoping that it would run a separate SoundPlayer and that two would play at the same time, however this did not work either. Any ideas are greatly appreciated!

Is This A Good Question/Topic? 0
  • +

Replies To: Running Multiple .Wav Files

#2 prajayshetty   User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 920
  • Joined: 27-April 07

Re: Running Multiple .Wav Files

Posted 02 April 2009 - 10:42 AM

i would suggest you that you create an xml file by using the xml reader class and the xml writer class and save the content to the xml file even windows media player saves its content in .wpl file and then load this content to the listbox and then let the user select one of the item from the listbox and let your program execute that particular item save it in the form of name and link you wil have to study the xml language a bit and for xml reader and writer class you can refer msdn or in other way you can save the content to a txt file as fallows
xyz;c:\\xyz.mp3


and then for the reading the content you can use the substring and indexof function

This post has been edited by prajayshetty: 02 April 2009 - 10:49 AM

Was This Post Helpful? 0
  • +
  • -

#3 painkiller102   User is offline

  • D.I.C Regular
  • member icon

Reputation: 18
  • View blog
  • Posts: 281
  • Joined: 27-February 08

Re: Running Multiple .Wav Files

Posted 02 April 2009 - 03:02 PM

View Postprajayshetty, on 2 Apr, 2009 - 09:42 AM, said:

i would suggest you that you create an xml file by using the xml reader class and the xml writer class and save the content to the xml file even windows media player saves its content in .wpl file and then load this content to the listbox and then let the user select one of the item from the listbox and let your program execute that particular item save it in the form of name and link you wil have to study the xml language a bit and for xml reader and writer class you can refer msdn or in other way you can save the content to a txt file as fallows
xyz;c:\\xyz.mp3


and then for the reading the content you can use the substring and indexof function

Its a great idea, however i am trying to only use C# and not any other tool. There is also a package that i could download but the computer i have to present my game to wont have it. So basically I am trying to write this with only C# code. (I am still in school so our school resource are limited and were only allowed to run certain things due to security risks). But thanks for the idea!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1