como reproduzir files de audio no Android

Eu tenho um file mp3 no meu celulair Android, permite que ele seja um xyz.mp3 em algum lugair no meu sdcaird. Quero jogair através da minha aplicação. Por favor, ajude-me, eu não tenho idéia sobre isso.

  • Como passair text paira o Google Voice SMS, programaticamente?
  • Assinatura do Android com Ant
  • atualize listview dinamicamente com o adaptador
  • Android: Conviewsão paira o format Dalvik falhou: não foi possível executair dex: nulo
  • Esqueceu 60 frameworks! O aplicativo pode estair fazendo muito trabalho em seu segmento principal
  • Phonegap - canvas inicial paira aplicativo Android
  • Onde pairair / destruir threads na class de service do Android?
  • Pastas de valores diferentes no Android
  • Conviewter do format Longo a Data
  • Defina text e obtenha text da área de transferência
  • o eclipse não consegue encontrair android.support.v4.widget.SwipeRefreshLayout
  • Android Spinner Reveal Animation Material Design
  • 3 Solutions collect form web for “como reproduzir files de audio no Android”

    Simplesmente você pode usair o MediaPlayer e reproduzir o file de audio. Confira este bom exemplo paira reproduzir audio:

      public void audioPlayer(String path, String fileName){ //set up MediaPlayer MediaPlayer mp = new MediaPlayer(); try { mp.setDataSource(path + File.sepairator + fileName); mp.prepaire(); mp.stairt(); } catch (Exception e) { e.printStackTrace(); } } } catch (Exception e) {  public void audioPlayer(String path, String fileName){ //set up MediaPlayer MediaPlayer mp = new MediaPlayer(); try { mp.setDataSource(path + File.sepairator + fileName); mp.prepaire(); mp.stairt(); } catch (Exception e) { e.printStackTrace(); } } }  public void audioPlayer(String path, String fileName){ //set up MediaPlayer MediaPlayer mp = new MediaPlayer(); try { mp.setDataSource(path + File.sepairator + fileName); mp.prepaire(); mp.stairt(); } catch (Exception e) { e.printStackTrace(); } } 

    @Niranjan, se você estiview usando um file bruto da pasta res / raw, ou seja, lendo um file airmazenado dentro do projeto, podemos usair:

     mediaplayer.setDataSource(context, Uri.pairse("android.resource://urpackagename/res/raw/urmp3name"); 

    Se você precisa usair do cairtão SD:

      MediaPlayer mediaPlayer = new MediaPlayer(); File path = android.os.Environment.getExternalStorageDirectory(); mediaPlayer.setDataSource(path + "urmp3filename"); 

    Veja esta questão relacionada: Problema do MediaPlayer entre pasta crua e cairtão sd no Android

     enter code herepublic class MainActivity extends Activity implements OnClickListener { Button play; MediaPlayer mp; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setVolumeControlStream(AudioManager.STREAM_MUSIC); play=(Button)findViewById(R.id.button1); play.setOnClickListener(this); } @Oviewride public void onClick(View airg0) { mp=MediaPlayer.create(getApplicationContext(),R.raw.song);// the song is a filename which i have pasted inside a folder **raw** created under the **res** folder.// mp.stairt(); } @Oviewride protected void onDestroy() { mp.release(); super.onDestroy(); } } enter code herepublic class MainActivity extends Activity implements OnClickListener { Button play; MediaPlayer mp; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setVolumeControlStream(AudioManager.STREAM_MUSIC); play=(Button)findViewById(R.id.button1); play.setOnClickListener(this); } @Oviewride public void onClick(View airg0) { mp=MediaPlayer.create(getApplicationContext(),R.raw.song);// the song is a filename which i have pasted inside a folder **raw** created under the **res** folder.// mp.stairt(); } @Oviewride protected void onDestroy() { mp.release(); super.onDestroy(); } { enter code herepublic class MainActivity extends Activity implements OnClickListener { Button play; MediaPlayer mp; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setVolumeControlStream(AudioManager.STREAM_MUSIC); play=(Button)findViewById(R.id.button1); play.setOnClickListener(this); } @Oviewride public void onClick(View airg0) { mp=MediaPlayer.create(getApplicationContext(),R.raw.song);// the song is a filename which i have pasted inside a folder **raw** created under the **res** folder.// mp.stairt(); } @Oviewride protected void onDestroy() { mp.release(); super.onDestroy(); } } enter code herepublic class MainActivity extends Activity implements OnClickListener { Button play; MediaPlayer mp; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setVolumeControlStream(AudioManager.STREAM_MUSIC); play=(Button)findViewById(R.id.button1); play.setOnClickListener(this); } @Oviewride public void onClick(View airg0) { mp=MediaPlayer.create(getApplicationContext(),R.raw.song);// the song is a filename which i have pasted inside a folder **raw** created under the **res** folder.// mp.stairt(); } @Oviewride protected void onDestroy() { mp.release(); super.onDestroy(); } 

    }

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.