MediaPlayer.Play throws exception on Android

I’ve ported a demo from XNA PC to Android and I’m getting an exception when playing a Music instance as follows:

            MediaPlayer.Play(toPlay);

Exception callstack is (sorry couldn’t figure out how to copy/paste):

Is this a known issue? Has anyone else encountered this? Are there any workarounds? I’m not really sure where to begin to debug this issue.

After a little bit of research it seems to have to do with the fact that “Prepare” isn’t given enough time to prepare the song before the song is told to play…but do I know how long it needs? I was expecting MonoGame to abstract this away so it works same as regular XNA.

I found out that if I put a breakpoint to artificially the time between song creation and playing it seems to play okay.

Now to figure out how to properly handle it in code…

For future readers: I was able to solve this by wrapping my code in a try/catch. If I get a “prepare failed: status=0x64” then I simply sleep the thread for 100 ms, then try again. This seemed to solve it in my automated test application. Not a very clean solution but I can’t think of anything better.