Xamarin-Plugins
Xamarin-Plugins copied to clipboard
No playback (Prepare failed.: status=0x1)
Hello, I'm using this component and it's working normally on several devices, but not on two devices with Android 10.
One of them is a Xiaomi Mi 9 SE, I debugged the device and got this error:
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) [0x0006e] in <42748fcc36b74733af2d99408>
at Java.Interop.JniPeerMembers + JniInstanceMethods.InvokeVirtualVoidMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue * parameters) [0x0002a] in <42748fcc36b7473382cc9407478afccd
at Android.Media.MediaPlayer.Prepare () [0x0000a] in <7d2292394f8c488b97f5bc2a0ac0240d>: 0
at Plugin.SimpleAudioPlayer.SimpleAudioPlayerImplementation.PreparePlayer () [0x00000] in F: \ dev \ open \ Xamarin-Plugins \ SimpleAudioPlayer \ SimpleAudioPlayer \ Plugin.SimpleAudioPlayer.Android \ SimpleAudioPlayerImplementation.cs: 139
at Plugin.SimpleAudioPlayer.SimpleAudioPlayerImplementation.Load (System.IO.Stream audioStream) [0x000a2] in F: \ dev \ open \ Xamarin-Plugins \ SimpleAudioPlayer \ SimpleAudioPlayer \ Plugin.SimpleAudioPlayer.Android \ SimpleAudioPlayerImplementation.cs: 120
at TagssApp.ChatTemplates.ChatMessageAudioOut.btPlayPause_Clicked (System.Object sender, System.EventArgs e) [0x00122] in D: \ _ Develop \ Github \ TagssApp \ TagssApp \ TagssApp \ TagssApp \ ChatTemplates \ ChatMessageAudioOut.xaml.cs
--- 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:1327)
at crc643f46942d9dd1fff9.ImageButtonRenderer.n_onClick (Native Method)
at crc643f46942d9dd1fff9.ImageButtonRenderer.onClick (ImageButtonRenderer.java:94)
at android.view.View.performClick (View.java:7250)
at android.view.View.performClickInternal (View.java:7227)
at android.view.View.access $ 3500 (View.java:819)
at android.view.View $ PerformClick.run (View.java:27749)
at android.os.Handler.handleCallback (Handler.java:883)
at android.os.Handler.dispatchMessage (Handler.java:100)
at android.os.Looper.loop (Looper.java:224)
at android.app.ActivityThread.main (ActivityThread.java:7562)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run (RuntimeInit.java falso39)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:950)
Plugin.SimpleAudioPlayer.ISimpleAudioPlayer audio = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
var st = File.OpenRead (currentItem.Path);
audio.Load (st); **// The error happens here.**
On my virtual machine running Android 10 it works normally.
Can someone help me?
The problem only happens with Xiaomi devices, as far as I could tell they don't touch .WAV
someone?
I have had this problem for a while now -- everything works fine on Samsung and Pixel devices but throws this error on OnePlus, Xperia and Xiaomi devices.
I've just noticed that I have the same issue on a OnePlus while it worked just fine on other devices like Pixel 2 and Samsung
Any updates?
I don't have access to any of these devices unfortunately.
You can try v1.5 which is using the newer Android SDK.
Solved by adding second silent channel, thus converting mono to stereo. And everything works. Issue is not related to plugin itself
@adrianstevens, on the version 1.5 the same problem exists. @vladikKBR85, could you share your solution? I don't understand what exactly did you do?
@vladikKBR85, could you share your solution? I don't understand what exactly did you do?
The underlying native android player fails to load monophonic sound for a some reason. I had to convert it to stereophonic sound on the server side. Using NAudio it should be something like:
using (var inputReader = new WaveFileReader(stream)){
var stereo = new MonoToStereoSampleProvider(inputReader.ToSampleProvider());
stereo.LeftVolume = 0.0f; // silence in left channel
stereo.RightVolume = 1.0f; // full volume in right channel
WaveFileWriter.WriteWavFileToStream(retStream, stereo.ToWaveProvider());
return retStream.ToArray();
}