public static void playSong(string fileName)
{
if (fileName.StartsWith(Directories.MUSIC))
fileName = fileName.Substring(Directories.MUSIC.Length);
System.Diagnostics.Debug.WriteLine(fileName);
if (fileName.Equals(currentSongName))
{
if (fadingOut)
{
fadeIn();
System.Diagnostics.Debug.WriteLine("FADE in");
}
return;
}
if (playing)
stopSong(); //cut off current song
if (!tryAllFileTypes(fileName))
{
throw new System.IO.FileNotFoundException("Could not find the music file \"" + fileName + "\" in the \"Music\" directory"
+ " in Content.\nMake sure the file is .mp3, .m4a, or .wma, and \"Copy to output directory\" settings"
+ " are set to \"Copy if newer\".");
}
if (wavePlayer == null)
wavePlayer = new WaveOutEvent(); //initialize wavePlayer
fadeInOut = new FadeInOutSampleProviderAdapted(file);
sampleToWave = new SampleToWaveProvider(fadeInOut);
wavePlayer.Init(sampleToWave);
if (!paused)
{
wavePlayer.Play();
playing = true;
}
currentSongName = fileName;
}