简体   繁体   English

Android和PC之间的双向通讯

[英]Two way communication between Android and PC

I am working on an Android application which is making real time communication between Android device and PC. 我正在开发一个Android应用程序,该应用程序在Android设备和PC之间进行实时通信。 I want to record audio signal and then send it to a server where it will be save to .wav file online. 我想记录音频信号,然后将其发送到服务器,然后将其在线保存到.wav文件。

By now I made an application which is streaming audio and playing it, but I want to save that bytes to a file on the computer. 到目前为止,我制作了一个应用程序,该应用程序可以流音频并播放音频,但是我想将该字节保存到计算机上的文件中。 The problem is that, can I send command from server which firstly starts an streaming applcation on Android and then send command which stops receiving bytes? 问题是,我可以从服务器发送命令,该服务器首先在Android上启动流应用程序,然后发送停止接收字节的命令吗? It will allows me to get array with bytes, which can be save to .wav file. 这将允许我获取带有字节的数组,可以将其保存到.wav文件中。 I'm using TCP protocol. 我正在使用TCP协议。

You may use a socket connection between you computer and the mobile device that the PC may use to notify that the android should start streaming (or even transfer the bytes stream through it). 您可以在计算机和移动设备之间使用套接字连接,PC可以使用该套接字连接来通知android应该开始流式传输(甚至通过它传输字节流)。

There is a bunch of libraries (on both client and server side) that implements socket communication. 有很多库(在客户端和服务器端)实现套接字通信。 Two big player there are: 有两个大玩家:

SignalR 信号R

Socket.io 套接字

You may also use the Android Socket API to implement that (if you don't want to use a third party library) 您也可以使用Android Socket API来实现这一点(如果您不想使用第三方库)

Socket - Android Developers 套接字-Android开发人员

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM