Search code examples
androidmedia-playerprogressdialog

How to show a progress dialog at loading audio on MediaPlayer obj


I want to load an audio file from internet on MediaPlayer object.

it's my code:

try {
    mp.setDataSource(AUDIO URL);
    mp.prepare();
    mp.start();
}
catch (IOException e) { e.printStackTrace(); }
catch (IllegalArgumentException e) { e.printStackTrace(); }
catch (IllegalStateException e) { e.printStackTrace(); }

but problem is that it's take a lot of time loading audio.

Help me to show a spinning progress dialog before loading audio to after that.

If question is incomplete tell me to complete decreasing.


Solution

  • Not quite a dublicate, but this question has a progress bar while preparing, it would be "quite" easy to modify to progress dialog or something else:

    Progress Bar while media player is preparing