majestic94 majestic94 - 2 months ago 21
Java Question

Android Radio App that streams my mp3 from a dropbox server

I have a dropbox media server that has a collection of mp3 files that I want to stream onto an android application.

I know that using the "MediaPlayer" is the best way to go in the API.

How my main concern is how do I automate the process, where music is being played one after another? As if it was like an internet radio app?

Could someone please point me in the correct location for guides or display example code would be great thank you in advance.

A.J A.J
Answer

Place the music files names in an arraylist (e.g songs) then implement onCompletionListener then set it to your media player. Inside the listener restart the media player to play the next item.

myMediaPlayer.setOnCompletionListener(this);

 public void onCompletion(MediaPlayer arg0) {
      arg0.release();
      if (counter < songs.size()) {
        counter++;
        arg0 = MediaPlayer.create(getApplicationContext(), songs.get(counter);
        arg0.setOnCompletionListener(this);
        arg0.start();
      }
    }