2 Replies - 1609 Views - Last Post: 12 October 2012 - 03:36 PM

#1 H2012   User is offline

  • New D.I.C Head

Reputation: 9
  • View blog
  • Posts: 25
  • Joined: 19-September 12

XNA, MediaPlayer, And The Desire To Have Song Changes

Posted 12 October 2012 - 03:21 PM

Hello and good evening everyone,


I'm working on a game with a friend of mine, and we're attempting to add audio to it. At this point, all we're wanting to add is just some background music that changes when the map changes, I.E. if you're in a forest map, it plays a forest song, if you're in a desert map, it plays a desert song.
We've been attempting to try this with MediaPlayer because we both have a dislike of WAV files, due to their size mainly and all other options I've seen only support WAV files (XACT, SoundEffect.)

And so to the problem.
I can get a song to play, that's no issue, however I can never get it to switch to another song when the map changes. Instead, it appears to be constantly reloading and replaying the song over and over again each time Update() is called. This causes lag to an unplayable level. The song will play, however, if I click and hold on any area other than the play area (like the "X" or bar up top.)
We've been trying to figure this out for days now and, quite honestly, I'm out of ideas on how to fix it, and my friend has never worked with MediaPlayer before I mentioned the problem to him, so I'm at the end of my rope.

Basically, I either need a solution to this, or I need another option to play sounds that use small (under 10 MB, preferably under 5 MB) files that will switch when the correct map is loaded.
Any and all help is appreciated at this point, and if you could keep your solutions, if you have any, in simple terms, I would appreciate that, as well, because I've only been coding in C# for about two months now.


Thank you for your time,
H2012

Is This A Good Question/Topic? 0
  • +

Replies To: XNA, MediaPlayer, And The Desire To Have Song Changes

#2 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6535
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: XNA, MediaPlayer, And The Desire To Have Song Changes

Posted 12 October 2012 - 03:32 PM

Sounds like everything is happening on one thread - the GUI thread.

You're going to have to look into multi-threaded design and have the music player class in its own thread.
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6247
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: XNA, MediaPlayer, And The Desire To Have Song Changes

Posted 12 October 2012 - 03:36 PM

Moved to XNA
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1