Sub AudioStream_RecordBuffer (Data() As Byte)
' taken from http://www.b4x.com/android/forum/threads/asyncstreams-tutorial.7669/#content
If sendingAudio Then
Dim msg As String
Dim bcon As ByteConverter
msg=BytesToString(Data,0,Data.Length,"UTF-8")
Log (msg)
'msg=bcon.StringToBytes(msg,"UTF-8")
Dim Data() As Byte
Data = msg.GetBytes("UTF8")
astream.Write(Data)
End If
End Sub
Sub astream_NewData (buffer() As Byte)
If sendingAudio = False Then
Dim msg As String
Dim bcon As ByteConverter
msg=BytesToString(buffer,0,buffer.Length,"UTF-8")
Log ("received data is: " & msg)
'msg=bcon.StringToBytes(msg,"UTF-8")
Dim buffer() As Byte
buffer = msg.GetBytes("UTF-8")
'play the received audio data
audioStream.Write(buffer)
End If
End Sub