android stream audio to server

老子叫甜甜 提交于 2019-11-30 04:03:55

Seems ok, but I would personally prefer to buffer the audio on the device and send it to the server from another thread instead of tying the recorder to the socket directly like you did. Because buffering locally will allow you to handle connection breaks gracefully.

Imagine you're recording and user goes through a tunnel and loses internet connection -- if you're streaming directly, the socket would close and the user would be annoyed :-) However, if you are buffering the data locally, you can reestablish the connection and continue sending the audio to the server from where you left off, and hopefully the user doesn't even have to know that a break in the connection just happened, because it just magically works.

In order to get that to work, you'd have to write the recording to a local buffer and have a separate thread check for new data on that buffer and send to the server as soon as possible.

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