How to play mp3 using c # ... without third dll

/ want to put a musical Easter egg in my app

Below SoundPlayer code is similar to mp3: - (

       Stream stream = new MemoryStream(Properties.Resources.MyMp3, false);
        using (SoundPlayer player = new SoundPlayer(stream))
        {
            player.PlaySync();
        } 

      

thank

+2


source to share


2 answers


You can use the Windows Media API.



See page .

+2


source


SoundPlayer only supports files .wav

. You have two options:

  • Use a different method like the one mentioned by Francis B
  • Convert MP3 to wav


Since this is internal to your application, I would convert it to wav and use SoundPlayer

it to reproduce it. The conversion will be a one-time process, so this is really the simplest solution.

+1


source







All Articles