adrianstevens/Xamarin-Plugins

Java.IO.IOException: Prepare failed.: status=0x1

StefanVam opened this issue · 2 comments

Hi,i got some errors like below in several device,most of devices is ok,I dont know why.Can anybody help me

Java.Lang.RuntimeException: java.lang.reflect.InvocationTargetException ---> Java.Lang.ReflectiveOperationException: Exception of type 'Java.Lang.ReflectiveOperationException' was thrown. ---> Java.IO.IOException: Prepare failed.: status=0x1
  at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) 

Below is my code,Is there something wrong?

player= Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
player.Load(stream);
player.Play();

Hi @StefanVam ,
I have the same issue, it is caused on Android 5.0.2 and it seems to be caused due to a code enhancement for android devices below version M in the OnPlaybackEnded method in the class SimpleAudioPlayerImplementation:

//this improves stability on older devices but has minor performance impact
if (Android.OS.Build.VERSION.SdkInt < Android.OS.BuildVersionCodes.M)
{
    player.SeekTo(0);
    player.Stop();
    player.PrepareAsync();
}

If you comment this section out, the issue should be fixed.

Have you tried your code with a newer version?
Cheers,
Yuval

Hi Yuval,
Thanks for your reply,I use 1.3.1 version now,I think my problem was caused by network issue,I just try catch it.I wanna let user try to play it again when issue occurs.I will continue to follow up this issue,I will try your method if this is not caused by network issue.