Hello friends I'm using this code to play sounds in mp3 and wav format in xna, I don't know how i can find out if the sound is completely played or not?
//Putting a sound in buffer for playing
fncPutAWavSoundOnBuffer(1);
fncPutAWavSoundOnBuffer(2);
public bool songbuffer = false;
public bool soundbuffer = false;
public Song CurrentSong;
public SoundEffect CurrentSound;
public void fncPutAMP3SoundOnBuffer(int code)
{
CurrentSong = content.Load<Song>(GivemeSoundFileNameByCode(code));
songbuffer = true;
}
public void fncPutAWavSoundOnBuffer(int code)
{
CurrentSound = content.Load<SoundEffect>(GivemeSoundFileNameByCode(code));
soundbuffer = true;
}
public string GivemeSoundFileNameByCode(int code)
{
string BaseDirectory = ".";
switch (code)
{
case 1:
{
return BaseDirectory + "\\StartPage\\Sounds\\ButtonMouseOverSound";
}
case 2:
{
return BaseDirectory + "\\StartPage\\Sounds\\ButtonClickSound";
}
case 3:
{
return BaseDirectory + "\\AddNewWordsPage1\\Sounds\\mp3PleaseWiteYourWordHere";
}
default:
{
break;
}
}
return "";
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
this.Exit();
PlaySound();
base.Update(gameTime);
}
public void PlaySound()
{
if (clsMyDefenition.soundbuffer)
{
clsMyDefenition.CurrentSound.Play();
clsMyDefenition.soundbuffer = false;
}
if (clsMyDefenition.songbuffer)
{
MediaPlayer.Play(clsMyDefenition.CurrentSong);
clsMyDefenition.songbuffer = false;
}
}