Reputation: 7480
I've recently added audio to my game loaded under the "Song" class from the XNA framework.
Everything seemed to work fine, until I decided to add the possibility to change the volume of the song, using the MediaPlayer.Volume setter.
However, when I try to change the volume for the first time, it runs really slowly(like 3 to 4 seconds, which is quite a lot for a volume change). After, when I try to change the volume again, the volume changes instantly.
Basically, I have three volume level choices: High, Medium and Low... So my problem is probably not because I change the volume level too often or too quickly.
I'd only like to know if any of you guys know when MediaPlayer.Volume can take more time to run, so I can check where my problem is situated.
Upvotes: 0
Views: 1209
Reputation: 27205
If you Google around you will find there are lots of performance issues with MediaPlayer. And often they depend on the system you are running on. This is due to it using Windows Media Player behind the scenes (on Windows).
Here are a few ways to mitigate the performance issues:
+=
to set it). Store the actual value yourself and only ever assign to it.If I had to guess (and I do) - I'd say that moving your volume changes to another thread will solve your problem.
Upvotes: 2