Note that there are some explanatory texts on larger screens.

plurals
  1. PObegining with android audio player
    primarykey
    data
    text
    <p>hey i'm working on simple audio player App in android. in this App i just want to play audio file from internet my code is as follows:</p> <pre><code>static MediaPlayer mPlayer; Button buttonPlay; Button buttonStop; String url = "http://android.programmerguru.com/wp-content/uploads/2013/04/hosannatelugu.mp3"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); buttonPlay = (Button) findViewById(R.id.play); buttonPlay.setOnClickListener(new OnClickListener() { public void onClick(View v) { mPlayer = new MediaPlayer(); mPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); try { mPlayer.setDataSource(url); } catch (IllegalArgumentException e) { Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show(); } catch (SecurityException e) { Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show(); } catch (IllegalStateException e) { Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show(); } catch (IOException e) { e.printStackTrace(); } try { mPlayer.prepare(); Toast.makeText(getApplicationContext(), "Preparing!", Toast.LENGTH_LONG).show(); Log.i("info","Preparing!"); } catch (IllegalStateException e) { Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show(); } catch (IOException e) { Toast.makeText(getApplicationContext(), "You might not set the URI correctly!", Toast.LENGTH_LONG).show(); } Toast.makeText(getApplicationContext(), "Prepared!", Toast.LENGTH_LONG).show(); Toast.makeText(getApplicationContext(), "Size="+(mPlayer.getDuration()/100)+" isPlaying="+mPlayer.isPlaying()+" isLooping="+mPlayer.isLooping(), Toast.LENGTH_LONG).show(); Log.i("info","Prepared!"); mPlayer.start(); Toast.makeText(getApplicationContext(), "Size="+(mPlayer.getDuration()/100)+" isPlaying="+mPlayer.isPlaying()+" isLooping="+mPlayer.isLooping(), Toast.LENGTH_LONG).show(); } }); buttonStop = (Button) findViewById(R.id.stop); buttonStop.setOnClickListener(new OnClickListener() { public void onClick(View v) { // TODO Auto-generated method stub if(mPlayer!=null &amp;&amp; mPlayer.isPlaying()){ mPlayer.stop(); } } }); } protected void onDestroy() { super.onDestroy(); // TODO Auto-generated method stub if (mPlayer != null) { mPlayer.release(); mPlayer = null; } } public void onCompletion(MediaPlayer mp) { Toast.makeText(getApplicationContext(), "Completed", Toast.LENGTH_LONG).show(); } </code></pre> <p>all is working fluently but music is not starting</p>
    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.
    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