我想了解如何套接字的工作,特別是我需要一些代碼示例服務器端接收設備從媒體記錄器發送的流。android stream音頻到服務器
非常感謝您的幫助。
我真正的最終目的是在設備上談話,並在PC上收聽,只是一個方向。
在那一刻,我能夠用下面的代碼來發送數據流:
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();
您在PC上使用哪種語言? – Axis 2012-01-06 19:16:11
我使用.NET平臺,vb.net或c#是一樣的。 – Giuseppe 2012-01-07 08:09:49