1

I am using a MediaPlayer to stream an .mp3 file from a server. This is the code:

   void start1(String a){
        mp.setDataSource(a);//mp is a properly initialized global MediaPlayer variable
        mp.setOnPreparedListener(this);
        mp.prepareAsync();
        }catch(Exception e){
            noerror=false;
            }
  }
 @Override
  public void onPrepared(MediaPlayer mp1){
        mp.start();
    }

The audio starts playing in around 5 seconds on Android API versions 17,16,15 and 14. But in all API versions below 14, the audio takes about 1 minute and 30 seconds to start. What should I do to decrease the time to 5 seconds?

vergil corleone
  • 1,071
  • 3
  • 15
  • 33
  • I must just say that this is rather weird, as I use this currently on API 10 it takes about 5 seconds as well to load my stream. – kabuto178 Jul 13 '13 at 08:12
  • @kabuto178 Ok, does it load in 5 secs on the emulator too? Because I am running my app on an emulator. Can you please check your app on an emulator with API version below 14? Thanks. – vergil corleone Jul 13 '13 at 09:49
  • yes i'm running this on an emulator now, it could be your connection or the stream itself, or your emulator network setup. – kabuto178 Jul 13 '13 at 10:06
  • @kabuto178 Maybe it's android's fault. The feed is live streaming, maybe that has something to do with it. – vergil corleone Jul 13 '13 at 10:13
  • is it possible to get the stream link to test it myself? – kabuto178 Jul 13 '13 at 10:23
  • @kabuto I tried running a live radio stream from shoutcast and it works in under 5 sec on API 13. But my feed doesn't.. Do you have any knowledge how to troubleshoot such a thing? Maybe its a buffer overflow or something like that... – vergil corleone Jul 13 '13 at 11:07
  • I don't have a real answer for this but this will help your app to be less frustrating for the user (http://stackoverflow.com/questions/6582908/why-does-it-take-so-long-for-androids-mediaplayer-to-prepare-some-live-streams/42042218#42042218) – LiTTle Feb 04 '17 at 15:44

0 Answers0