Home > Blockchain >  System.InvalidOperationException: "Sound API only supports playing PCM wave files."
System.InvalidOperationException: "Sound API only supports playing PCM wave files."

Time:12-11

SoundPlayer simpleSound = new SoundPlayer("C:/Users/heerm/Downloads/mixkit-positive-interface-beep-221.wav");
simpleSound.Play();

This code occures the in the title named error massage and I don´t know how to convert a wav-file into pcm wave files or how to play different fileformats with winforms. Can anyone help me?

CodePudding user response:

If we want to play wav files in winform, we can use the following code:

using System.Media;
private void Play_Click(object sender, EventArgs e)
    {
        SoundPlayer soundPlayer = new SoundPlayer(@"Sound Path");
        soundPlayer.Play();
    }

This method can play wav files normally. If you still get the error “ Sound API only supports playing PCM wave files”, there are some problem with your sound file format like this: Sound API only supports playing PCM wave files

And this page can give you some suggestions on converting to pcm wave files. https://social.msdn.microsoft.com/Forums/en-US/d30a3002-a553-4bb2-b8da-058255395a5e/the-error-occured-when-i-tried-to-play-wav-file-winforms?forum=netfxbcl

  • Related