I am using a MediaPlayer
to stream audio from a URL.
According to the documentation, calling the MediaPlayer
pause
followed by a play
will resume from the point where it was paused.
I am wondering how this works with a live audio stream. When I call pause
is the MediaPlayer
creating some sort of buffer of all the incoming data, and storing it until I call play
again?
If this is indeed the case, is there a max size on this buffer? I am mainly concerned about a user pausing the MediaPlayer
and it using a lot of memory while it stores incoming audio data.
As, I understand you are using Mediaplayer for streaming audio from a URL.. something like radio channels. In this process, you are using buffers. So, the behaviour you are getting is quite obvious. When you pause, your data will continue to store and on resuming the stream, it will start from the point it was paused.
But streaming should not behave in this manner unlike stored audio which start from the point it was paused. Streaming audio should always start from the live streaming at that point. So, onPause, you should free the buffers. When the user resumes again, you can restart the stream the way you did it first time. This is how the behavior should be.
If you check out, normal radio streaming is implemented in most of the radio streaming apps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With