我想了解socket是如何工作的,特别是我需要服务器端的一些代码示例来接收来自mediarecorder从设备发送的流.
非常感谢您的帮助.
我真正的最终目的是在设备上讲话并在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();
Run Code Online (Sandbox Code Playgroud) 如何在不添加标记的情况下在Android上的Google Maps Activity中的特定位置显示消息?我只想显示一个小的弹出动画,其中包含特定坐标处的消息。
是否有可以执行此特定任务的GitHub库?