Async Mp3 Player Demo : Mp3 « Media « Android






Async Mp3 Player Demo

 
package app.test;

import android.app.Activity;
import android.media.AsyncPlayer;
import android.media.AudioManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;

public class MainActivity extends Activity {
    private static final String TAG = "AsyncPlayerDemo";
    private AsyncPlayer mAsync = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        mAsync = new AsyncPlayer(TAG);
        mAsync.play(this, Uri.parse("file://" + 
            Environment.getExternalStoragePublicDirectory(
                Environment.DIRECTORY_RINGTONES) + 
                "/my.mp3"),      
                false, AudioManager.STREAM_MUSIC);
    }
    
    @Override
    protected void onPause() {
      mAsync.stop();
      super.onPause();
    }
}

   
  








Related examples in the same category

1.Mp3 Player
2.Play mp3 file within a service
3.Play Mp3 file from a Url
4.Load Mp3 file from local file system