I'm developing a simple PTT() Cross platform application with Xamarin.Forms. I have AudioRecorder.Plugin for recording and CrossSimpleAudioPlayer for playing the stream. I use nodejs and socket.io for the server part.
I send the recorded audio to the nodejs server every 5 secs. with the recorder.StartRecording() method.
buffer = new byte[recorder.GetAudioFileStream().Length];
await recorder.GetAudioFileStream().ReadAsync(buffer, 0, buffer.Length);
socket.Emit("AudioData", System.Convert.ToBase64String(buffer, 0, buffer.Length));
Nodejs and socketio part seems pretty OK. cause i can see the data from the console log without any problem.
Below code is the playing part and it tries to convert data to stream and than plays.
socket.On("inboundData", (data) =>
{
byte[] byts = Convert.FromBase64String(data.ToString());
using (MemoryStream strm = new MemoryStream(byts))
{
var player = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
player.Load(strm);
player.Play();
}
});
But just before the playing part I get an (Java.IO.IOException: Prepare failed.: status=0x1) error.
Any help will be appreciated.