Streaming Real time Audio

回眸只為那壹抹淺笑 提交于 2019-11-30 14:20:59
Micky

You can use sockets as so:

String hostname = "1.2.3.4";
int port = 865;

Socket socket = null;

try {
    socket = new Socket(InetAddress.getByName(hostname), port);
} catch (Exception e) {

    e.printStackTrace();
}

ParcelFileDescriptor socketedFile = ParcelFileDescriptor.fromSocket(socket);

Then set the socketedFile to the output file (socketedFile.getFileDescriptor()) of the audio recorder. This will send it up as bytes.

Alternatively to make it more stable, write out the data from the MediaRecorder to a local buffer and then have a separate thread check that buffer and write it to the socket instead, to allow for small disconnections in the socket connection.

See this question for more information: android stream audio to server

Obviously you then need to have an application running on a server to receive your bytes and turn that into audio data.

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