When calling MediaPlayer.Play(mysong); I get an exception “Java.IO.IOException: Prepare failed.: status=0x1”
I’ve tried several files…
In monogame pipeline tool I’ve tried .ogg files, .mp3 files, and with the mp3 file I tested the wma file it created and it was fine
Anyone know what causes this? Also, I checked the xnb files in hex editor and they all reference .wma files. I’ve checked to make sure the xnb and .wma files are making it to the android.bin/anyCPU/Debug/Content folder.
My emulater is Android 8.1(API Level 27 - Oreo) I’m using Visual Studio.
Your help is greatly appreciated.
Full exception:
Java.IO.IOException: Prepare failed.: status=0x1
03-15 04:42:30.891 I/mono-stdout(15388): at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <8acc8089c2ed40d08469fbaa6710a44c>:0
03-15 04:42:30.891 I/mono-stdout(15388): at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in <8acc8089c2ed40d08469fbaa6710a44c>:0
03-15 04:42:30.892 I/mono-stdout(15388): at Android.Media.MediaPlayer.Prepare () [0x0000a] in <6f8818d6ffa14f4bad6fb5f5d0f0e665>:0
03-15 04:42:30.892 I/mono-stdout(15388): at Microsoft.Xna.Framework.Media.Song.Play (System.Nullable1[T] startPosition) [0x0005f] in <14285e7be6444bda94a4048e3cb68e5b>:0 03-15 04:42:30.892 I/mono-stdout(15388): at Microsoft.Xna.Framework.Media.MediaPlayer.PlatformPlaySong (Microsoft.Xna.Framework.Media.Song song, System.Nullable1[T] startPosition) [0x0003e] in <14285e7be6444bda94a4048e3cb68e5b>:0
03-15 04:42:30.892 I/mono-stdout(15388): at Microsoft.Xna.Framework.Media.MediaPlayer.PlaySong (Microsoft.Xna.Framework.Media.Song song, System.Nullable1[T] startPosition) [0x0001c] in <14285e7be6444bda94a4048e3cb68e5b>:0 03-15 04:42:30.892 I/mono-stdout(15388): at Microsoft.Xna.Framework.Media.MediaPlayer.Play (Microsoft.Xna.Framework.Media.Song song, System.Nullable1[T] startPosition) [0x00042] in <14285e7be6444bda94a4048e3cb68e5b>:0
03-15 04:42:30.892 I/mono-stdout(15388): at Microsoft.Xna.Framework.Media.MediaPlayer.Play (Microsoft.Xna.Framework.Media.Song song) [0x00000] in <14285e7be6444bda94a4048e3cb68e5b>:0
03-15 04:42:30.892 I/mono-stdout(15388): at MonoGame.MonkeyTap.Game1.LoadContent () [0x0003b] in C:\dev\xammono\MonoGame.MonkeyTap\MonoGame.MonkeyTap\Game1.cs:72
03-15 04:42:30.892 I/mono-stdout(15388): — End of managed Java.IO.IOException stack trace —
03-15 04:42:30.892 I/mono-stdout(15388): java.io.IOException: Prepare failed.: status=0x1
03-15 04:42:30.892 I/mono-stdout(15388): at android.media.MediaPlayer._prepare(Native Method)
03-15 04:42:30.892 I/mono-stdout(15388): at android.media.MediaPlayer.prepare(MediaPlayer.java:1278)
03-15 04:42:30.892 I/mono-stdout(15388): at mono.java.lang.RunnableImplementor.n_run(Native Method)
03-15 04:42:30.893 I/mono-stdout(15388): at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
03-15 04:42:30.893 I/mono-stdout(15388): at android.os.Handler.handleCallback(Handler.java:790)
03-15 04:42:30.893 I/mono-stdout(15388): at android.os.Handler.dispatchMessage(Handler.java:99)
03-15 04:42:30.893 I/mono-stdout(15388): at android.os.Looper.loop(Looper.java:164)
03-15 04:42:30.893 I/mono-stdout(15388): at android.app.ActivityThread.main(ActivityThread.java:6494)
03-15 04:42:30.893 I/mono-stdout(15388): at java.lang.reflect.Method.invoke(Native Method)
03-15 04:42:30.893 I/mono-stdout(15388): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
03-15 04:42:30.893 I/mono-stdout(15388): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
I don’t think it matters does it? I was following this tutorial which has the line to play in load content. Has something changed I. The library so that this is not okay now? FYI also used assets from this as well as tested with mp3s.
So, I did test it with a windows app instead of android and it works. Is there some setting in the manifest I need to request to gain access to audio? I also tried setting timers and moving the play code, even retrying, in a loop but that didn’t work.
I’m experiencing the same issue with Xamarin.Android specifically not liking the MediaPlayer.Play from a Content Pipeline mp3 asset. Works fine with UWP. I’m using MonoGame.Framework.Android v3.7.1.189,
I’m running into this issue, suddenly none of my MonoGame.Android apps will play music and throw this error. Does anyone know the source of this problem, or how to solve it?
stack trace:
at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in <af1c6fdcff1a4da4a0e44a8cdef352da>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0002a] in <af1c6fdcff1a4da4a0e44a8cdef352da>:0
at Android.Media.MediaPlayer.Prepare () [0x00000] in /Users/runner/runners/2.164.1/work/1/s/xamarin-android/src/Mono.Android/obj/Release/android-28/mcw/Android.Media.MediaPlayer.cs:3554
at Microsoft.Xna.Framework.Media.Song.Play (System.Nullable`1[T] startPosition) [0x0005f] in <4e0823396e3e485a8fd37382a8af022e>:0
at Microsoft.Xna.Framework.Media.MediaPlayer.PlatformPlaySong (Microsoft.Xna.Framework.Media.Song song, System.Nullable`1[T] startPosition) [0x0003e] in <4e0823396e3e485a8fd37382a8af022e>:0
at Microsoft.Xna.Framework.Media.MediaPlayer.PlaySong (Microsoft.Xna.Framework.Media.Song song, System.Nullable`1[T] startPosition) [0x0001c] in <4e0823396e3e485a8fd37382a8af022e>:0
at Microsoft.Xna.Framework.Media.MediaPlayer.Play (Microsoft.Xna.Framework.Media.Song song, System.Nullable`1[T] startPosition) [0x00041] in <4e0823396e3e485a8fd37382a8af022e>:0
at Microsoft.Xna.Framework.Media.MediaPlayer.Play (Microsoft.Xna.Framework.Media.Song song) [0x00000] in <4e0823396e3e485a8fd37382a8af022e>:0
at AudioBuddy.AudioManager.Update (Microsoft.Xna.Framework.GameTime gameTime) [0x00021] in C:\Projects\AudioBuddy\AudioBuddy.SharedProject\AudioManager.cs:292
--- End of managed Java.IO.IOException stack trace ---
java.io.IOException: Prepare failed.: status=0x1
at android.media.MediaPlayer._prepare(Native Method)
at android.media.MediaPlayer.prepare(MediaPlayer.java:1274)
at mono.java.lang.RunnableImplementor.n_run(Native Method)
at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:30)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)