I need to play live audio stream, actually it is radio. The problem is that I also need to manage 20 minute buffer for stream. As far as I understand it's not easy to implement with adnroid.
First I checked MediaPlayer, but it doesn't provide any methods for buffer managment. In fact you even can't set buffer size directly.
Secondly I tried to manage buffer using local files: progressively download the stream to a temporary files and switch them. But when you want to switch to following file (change datasource in MediaPlayer), audio is not played continuously. You can hear short interruptions.
The last idea is to use stream proxy. Usually it is used for playing streams in Adnroid versions below 8. In stream proxy you create ServerSocket, read from audio stream and write to player. So actually I can manage buffering there. I can cache stream and write to MediaPlayer whatever I want. But. It doesn't work with Android 8.
I got exception: Connection reset by peer java.net.SocketException: Connection reset by peer. MediaPlayer 8 doesn't want to read data from socket.
Thus I have two questions:
1) What other way to implement stream buffering?
2) how to adapt StreamProxy for android 8?
Any ideas are appreciated.