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();
}
}