I have a Media Player service that plays an Internet stream, but I am having problems with the display in my xml percent of buffering, at the moment I'm just showing a message, since all the ways I tried gave me a static long number. Here is the code from my service:
@Override public void onBufferingUpdate(MediaPlayer mp, int percent) { setBufferPosition(percent * getMusicDuration() / 100); myMain.EstadoRadio.setText(" Reproductor \n Buffering... "); }
as you can tell, EstadoRadio is a text view in my xml that works with myMain activity, where I want to display% stream buffering. Thank you for your help.
EDIT: I saw in most cases where the "percentage" from onBufferingUpdate (MediaPlayer mp, int percent) is used, something like this:
myMain.EstadoRadio.setText(" Reproductor \n" + percent + "%");
but in my case the percentage is always -2147483648, I don’t know why, or why it doesn’t change or update, here is a little from my cat log:
05-17 13:34:37.005: V/MediaPlayer(25382): message received msg=3, ext1=-2147483648, ext2=0 05-17 13:34:37.005: V/MediaPlayer(25382): buffering -2147483648 05-17 13:34:37.005: V/MediaPlayer(25382): callback application 05-17 13:34:37.005: V/MediaPlayer(25382): getDuration 05-17 13:34:37.015: V/MediaPlayer(25382): back from callback 05-17 13:34:38.016: V/MediaPlayer(25382): message received msg=3, ext1=-2147483648, ext2=0 05-17 13:34:38.016: V/MediaPlayer(25382): buffering -2147483648 05-17 13:34:38.016: V/MediaPlayer(25382): callback application 05-17 13:34:38.016: V/MediaPlayer(25382): getDuration 05-17 13:34:38.016: V/MediaPlayer(25382): back from callback
zvzej source share