Note that there are some explanatory texts on larger screens.

plurals
  1. POProgress Bar while media player is preparing
    primarykey
    data
    text
    <p>I am trying to figure out how to have a progress bar that says "Loading. Please Wait..." while my media player prepares a streaming file. What occurs now is that it displays after the song is prepared. how can i fix this? </p> <pre><code> mediaPlayerLoadingBar =ProgressDialog.show(PlaylistActivity.this, "", "Loading. Please wait...", true); /*dubstep stream*/ try { dubstepMediaPlayer.setDataSource(dubstepPlaylistString[0]); dubstepMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); dubstepMediaPlayer.prepare(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SecurityException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } dubstepMediaPlayer.start(); if(dubstepMediaPlayer.isPlaying()){ mediaPlayerLoadingBar.dismiss(); }` </code></pre> <p>EDIT: This is the code I have now:</p> <p>`switch(pSelection){ case 1:</p> <pre><code> new AsyncTask&lt;Void, Void, Void&gt;(){ @Override protected void onPreExecute(){ mediaPlayerLoadingBar =ProgressDialog.show(PlaylistActivity.this, "", "Loading. Please wait...", true); try { dubstepMediaPlayer.setDataSource(dubstepPlaylistString[0]); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } dubstepMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); } @Override protected Void doInBackground(Void... params) { // TODO Auto-generated method stub //mediaPlayerLoadingBar =ProgressDialog.show(PlaylistActivity.this, "", "Loading. Please wait...", true); return null; } protected void onPostExecute(Void result){ //mediaPlayerLoadingBar =ProgressDialog.show(PlaylistActivity.this, "", "Loading. Please wait...", true) dubstepMediaPlayer.prepareAsync(); dubstepMediaPlayer.start(); mediaPlayerLoadingBar.dismiss(); } }.execute();` </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload