Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MediaPlayer pause() behaviour

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.

like image 615
Tyler Avatar asked Mar 03 '14 00:03

Tyler


1 Answers

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.

like image 120
Sushil Avatar answered Nov 12 '22 21:11

Sushil