我不确定你真的想要什么但可能是this答案可以帮到你。 也读了原来的问题,以确保它是你有同样的问题。
试试这个代码:
String hostname = "192.168.1.10";
int port = 8000;
Socket socket = null;
try {
socket = new Socket(InetAddress.getByName(hostname), port);
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket);
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setOutputFile(pfd.getFileDescriptor());
try {
recorder.prepare();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
recorder.start();
来源
2013-12-10 08:45:32
Val
雅我正在使用包裹文件描述符发送音频文件到服务器端,但我再也能够通过使用包裹文件描述符笏的原因玩? – Aravi
这段代码适合你吗? – Val
没有它没有工作... – Aravi