Android: How to record mp3 radio (audio) stream

后端 未结 2 506
独厮守ぢ
独厮守ぢ 2020-12-02 13:56

My favorite Radio station plays a radio audio stream in mp3 format. In my android application I can receive and play it without any problem.

How can I implement a re

相关标签:
2条回答
  • 2020-12-02 14:25

    Maybe you should read audio stream "byte by byte" and then place it into new file? Like a simple file copy operation, using inputstream-outputstream.

    0 讨论(0)
  • 2020-12-02 14:37

    Perfect! Reading the audio stream "byte by byte" is the solution. Thank you!!

    Here my code snippets:

            URL url = new URL("http://myradio,com/stream.mp3");
            inputStream = url.openStream();
            Log.d(LOG_TAG, "url.openStream()");
    
            fileOutputStream = new FileOutputStream(outputSource);
            Log.d(LOG_TAG, "FileOutputStream: " + outputSource);
    
            int c;
    
            while ((c = inputStream.read()) != -1) {
                Log.d(LOG_TAG, "bytesRead=" + bytesRead);
                fileOutputStream.write(c);
                bytesRead++;
            }
    
    0 讨论(0)
提交回复
热议问题