I'm creating a C# application, in which I need to reproduce a MP3 file. As soon as the file has been completely reproduced (not before) I want execute other methods.
The problem is that, since surely a thread is used for reproduce sounds, all the subsequent actions are executed immediately, without waiting for the complete reproduction of the mp3 file.
The code is:
gioco.playSound(true);
if (gioco.feedbackNao && naoConnect)
{
nao.talkNao("Bravo! Continua così.");
}
else if (gioco.feedbackVocale && speech.isFound)
{
speech.pronunciaFraseCorretta();
}
#Class UtilityGame
public void playSound(bool rispostaCorretta)
{
playerOK = new WMPLib.WindowsMediaPlayer();
playerOK.URL = Directory.GetCurrentDirectory() + "/Resources/Sound/ok.mp3";
playerOK.controls.play();
}
So, when I try to execute playSound
method, at the first line, the next instructions are processed before the sounds ends.