Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Xamarin.Forms Cross Mic Audio Streaming with AudioRecorder and CrossSimpleAudioPlayer

$
0
0

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.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>