i am using wave audio component on vcl project and i am using TliveAudiorecorder to send audio in memorystream to indy tcp server and the server side send this stream back to indy tcp clients
clients that uses vcl application receive the audio on normally and play it with Tliveaudioplayer
but i wonder can i read and play this stream on android ?
i tried to simulate the player so i used the Android API AudioTrack to play this stream at the following code i have set audiotrack encoding same as the encoding i have used to record data on vcl using the liveaudiorecorder which was Mono 16bit 8000 HZ but when ever the stream arrived the android app crashed and closed when the following line called
MSCLIENT.ReadBuffer(AudioStream.Data^, AudioDataSize);
(AudioPlay as JAudioTrack).write(AudioStream, 0, AudioDataSize);
var
Enable_Play: Boolean;
AudioPlay: JAudioTrack;
AudioStream: TJavaArray<SmallInt>;
Audiodataset: Integer;
Audiodataset := TJAudioTrack.JavaClass.getMinBufferSize(8000,
TJAudioFormat.JavaClass.CHANNEL_OUT_MONO,
TJAudioFormat.JavaClass.ENCODING_PCM_16BIT);
AudioStream:= TJavaArray<SmallInt>.Create(Audiodataset);
AudioPlay:= TJAudioTrack.JavaClass.init(TJAudioManager.JavaClass.STREAM_MUSIC,
8000,
TJAudioFormat.JavaClass.CHANNEL_OUT_MONO,
TJAudioFormat.JavaClass.ENCODING_PCM_16BIT,
Audiodataset,
TJAudioTrack.JavaClass.MODE_STREAM);
//recive audio
if Command = ‘Stream’ then
begin
Sleep(0);
if (MSTream.Size > 10) then
begin
if Enable_Play <> True then
begin
Enable_Play:= True;
(AudioPlay as JAudioTrack).play();
end;
AudioDataSize := MSTream.Size;
MSCLIENT.ReadBuffer(AudioStream.Data^, AudioDataSize);
(AudioPlay as JAudioTrack).write(AudioStream, 0, AudioDataSize);
end;
end;
i don’t know if what i am thinking right that i can play recorded audio that saved on memorystream within vcl project into android .