Song cutting off prematurely

hmm… Unfortunately, I have always used the other template, never the openGL, so I cant be of any further help. :frowning:

1 Like

I appreciate the help, anyway! Thank you!

Have you got your project up on github or anywhere, or can you share specific parts of code we can run?

I do indeed. Let me make it public so you can clone it. Give me a few hours though, as I’m not at home.

Sorry for the double post, just going to dump this link to my repo here:
https://bitbucket.org/nosrick/joy

I have this exact same issue. Did you ever get this working properly? Or did you resort to adding the right amount of silence to the end of your track?

So yup, my solution was just to add 1 second of silence to the end of the track in Audacity. It does the trick so I guess it doesn’t matter, but it seems like the hackish solution and surely there’s an explanaition to why it’s happening to us and not others.

Info:
I’m developing on Linux, building for DesktopGL, and using the content pipeline to import the original .wav file as a song.
Development build of monogame.
Development build of monogame.extended (if for some reason that would matter…)

Sorry for bumping this, but I’m having the exact same issue and I haven’t been able to find anything else on this. Using MonoGame 3.7.0.678. (latest build available on the website). I’m developing on Windows 10 and created the project with the cross platform desktop template (OpenGL).

I’m loading and playing ogg music files like so:

var song = content.Load<Song>("ogg/" + name);
MediaPlayer.Play(song);

The music cuts off about a second too soon on every clip I’ve tried. As a last resort I’ll use Romans_I_XVI’s solution, but it seems pretty hacky and I’d prefer a cleaner solution.

I’ve found an acceptable workaround until this is fixed:

In the content pipeline, convert all the music files from Song to SoundEffect. Then load music as a SoundEffect, create a SoundEffectInstance from it, and play it that way.

SoundEffect backgroundMusic = content.Load<SoundEffect>("ogg/" + name);
currentMusicInstance = backgroundMusic.CreateInstance();
currentMusicInstance.IsLooped = true;
currentMusicInstance.Volume = 0.1f;
currentMusicInstance.Play();

Using this method, the entire track plays and loops flawlessly. The downside is that this tripled the size of my project (~50 MB to ~150 MB) since the music files are no longer compressed ogg files.

This was fixed here: https://github.com/MonoGame/MonoGame/pull/5821

You either have to compile MonoGame yourself or wait until 3.7 is released. I’ve tested it also with FNA and there it worked without a problem.

Great news, thanks for the heads up.

I installed the latest development build from the website (3.7.0.849) and tested it on my Windows 10 machine and it’s definitely better, but the loops still aren’t as flawless as simply playing a SoundEffect on loop. Some tracks have a short delay between loops, and some are still looping maybe a half second too soon. I’ll test on my Mac later on and see if it’s the same.