简体   繁体   English

将Ogg文件上传到Android中的音频流

[英]Upload Ogg File to audio streaming in Android

I am noob in internet radio application. 我在互联网广播应用程序方面很菜鸟。 I am using icecast for this audio streaming so first here in my android application I captured the audio bytes in ogg file so I want to send this file for audio streaming. 我正在使用icecast进行音频流传输,因此首先在android应用程序中,我捕获了ogg文件中的音频字节,因此我想将此文件发送以进行音频流传输。

My question How would I send this either complete *.ogg file or in some other format ?? 我的问题我将如何发送完整的* .ogg文件或其他格式的文件? Any help please 任何帮助请

Here is my connect to icecast that is working 这是我连接到正在运行的Icecast

Socket s = new Socket("101.57.116.17", 8000);
Socket s = new Socket("101.57.116.17", 8000);
Log.d("VS", "Socket Created");
OutputStream out = s.getOutputStream();
Log.d("VS", "Output Stream Established");
PrintWriter output = new PrintWriter(out);
Log.d("VS", "Send Header");
output.println("SOURCE /app ICE/2.3.3");
output.println("content-type: audio/mpeg");
output.println("Authorization: Basic c291cmNlOmhhY2ttZQ==");
output.println("ice-name: Server");
output.println("ice-genre: Rock");
output.println("ice-bitrate: 128");
output.println("ice-private: 0");
output.println("ice-public: 1");
output.println("ice-audio-info: ice-samplerate=44100;ice-bitrate=128;ice-channels=2");
output.println("");
output.flush();
Log.d("VS", "Header sent");
BufferedReader reader = new BufferedReader(new InputStreamReader(
        s.getInputStream()));
String response = reader.readLine();
Log.v(LOG_TAG, response);

HttpClient client = new DefaultHttpClient();

HttpGet httpGET = new HttpGet(
        "http://101.57.116.17:8000/admin/metadata?pass=hackme&mode=updinfo&mount=/app&song=akon");
httpGET.setHeader("Authorization", "Basic c291cmNlOmhhY2ttZQ==");
httpGET.setHeader("User-Agent", "(Mozilla Compatible)");

HttpResponse metaDataResponse = client.execute(httpGET);

System.out.println("Response Code : "
        + metaDataResponse.getStatusLine().getStatusCode());

BufferedReader rd = new BufferedReader(new InputStreamReader(
        metaDataResponse.getEntity().getContent()));

StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
    result.append(line);
}

Once you have connected to the Icecast server and have been authorized, simply start sending your stream data down the same connection. 连接到Icecast服务器并获得授权后,只需开始通过同一连接发送流数据即可。

Note that you need to do this at the rate at which the playback occurs. 请注意,您需要以发生回放的速度执行此操作。 Otherwise, you will overrun a buffer and the audio for the client either won't work at all, or will skip around. 否则,您将超出缓冲区,客户端的音频将根本无法工作,或者会跳来跳去。

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

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