To play I wave file I do:
SoundPlayer p = new SoundPlayer(@"myWaveFile.wav");
p.Play();
Some wav files cannot play for some reason. For example when trying to play this wave file I get an error:
SoundPlayer p = new SoundPlayer(@"c:\Windows\Media\Afternoon\Windows Balloon.wav");
p.Play();
// the exception that I get is: Sound API only supports playing PCM wave files.
I am looking for a method that could tell me if I could play the wave file such as this method
public void CanPlayWaveFile(string file)
{
SoundPlayer p = new SoundPlayer(file);
try
{
p.Play();
return true;
}
catch
{
return false;
}
}
the problem with that method is that I might not want to play the audio I just want to know if I can play that file. Also I don't want to have to wait for the wave file to finish playing in order to see if I can play that file later or not. So how can I know if a wave file has this PCM format. It will be nice if a method SoundPlayer.CanPlayFile() existed.
Edit
I see people help me see how I can play other formats or convert this format. I don't want to convert it to other formats. I just want to know if I can play them or not without having to have the try catch block...