Android AudioRecord to Server over UDP Playback Issues

此生再无相见时 提交于 2019-11-29 19:55:23

Here's something you could try, instead of:

// read the data into the buffer
recorder.read(buffer, 0, buffer.length);

// place contents of buffer into the packet
packet = new DatagramPacket(buffer, buffer.length, serverAddress, PORT);

Do not expect you received fully read buffer from recorder but use actual read value instead

// read the data into the buffer
int read = recorder.read(buffer, 0, buffer.length);

// place contents of buffer into the packet
packet = new DatagramPacket(buffer, read, serverAddress, PORT);

Or something alike.

FrenzyMorphy

Thanks for post Joshua .... great help for new bees :)

volumeControl.setValue(volumeControl.getMaximum());

removes illegalStateException at Server

and permission in android client

<uses-permission android:name="android.permission.RECORD_AUDIO"/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!