Hello,
I am using this example to send a wave file through MQTT between two applications, one written in B4i and the other in B4A. The B4i can play a B4A wave file recorded in B4A, but B4A cannot play a wave file recorded by B4i.
B4i code
B4a Code
I am using this example to send a wave file through MQTT between two applications, one written in B4i and the other in B4A. The B4i can play a B4A wave file recorded in B4A, but B4A cannot play a wave file recorded by B4i.
B4i code
Code:
sub btnStartRecording_Click
streamer.Initialize(File.DirDocuments, mFileName, 44100, True, 16, False)
streamer.Record
timer1.Enabled = True
Timer1_Tick
Catch
Log("btnRecord_Click " & LastException.description)
End Try
End Sub
Sub btnsumbitSound_Click
Starter.SendAudio(File.ReadBytes(File.DirDocuments, mFileName))
End Sub
Public Sub SendAudio(SoundData() As Byte)
If connected Then
SBS.Initialize
SBS.Append("Recored").Append("/Audiosend")
Dim sendAudioStr As String=SBS.ToString
client.Publish2(sendAudioStr, serializator.ConvertObjectToBytes(SoundData),1,False)
Else
hd.ToastMessageShow("It is not connected",False)
End If
End Sub
B4a Code
B4A code:
Private Sub client_MessageArrived (Topic As String, Payload() As Byte)
Dim receivedObject As Object = serializator.ConvertBytesToObject(Payload)
Dim WaveSound() As Byte = receivedObject
Dim SendFileName As String
Dim SBS As StringBuilder
SBS.Initialize
SBS.Append("filename").Append(".wav")
SendFileName=SBS.ToString
BytesToFile (File.DirInternal,SendFileName, WaveSound)
End Sub
Sub play_click
If filename.EndsWith(".wav") Then
mp.Load(File.DirInternal,filename)
mp.Play
End If
End Sub
Last edited: