Embedding Music into an Executable (Windows)

Hi everyone,

We’ve managed to embed all our assets (images, fonts, sfx, csv) for windows but music is particularly tricky, and would love if anyone has any experience or suggestions.

Previously we processed the mp3 files through the Monogame Content Pipeline, so it shows up in the output directory, which is obviously not what is desired for distribution.

We are using the Song class, and here are the different methods we’ve tried:
(1) Using Resource Content Manager (resx file)

  • This method reads an xnb, doing otherwise would throw an error.
  • Music comes in xnb and wma pairs, trying to add only xnb would throw another error. However, trying to add the wma into the resx file will rename it with an additional ‘1’ behind, since it does not accept duplicate names, even if it is a different file format.
    (2) Streams
  • Song class does not seem to be compatible with loading from streams. (the idea was to read from the embedded resource stream)
    (3) Uri
  • If the mp3 is not set to copy to the output directory, there is no file to read.
  • mp3s set to Embedded Resource built action do not seem to have any proper file path since it is embedded.
    (4) Streaming from the mp3 embedded resource and saving the file into a temporary folder. Then loading the song file into memory, before deleting the file. This method has actually worked, and is the method we will go with should no other solution work. But it does feel a little hacky.

Any thoughts, suggestions are greatly appreciated!

Thanks!