package my.name;

import android.content.Context;
import android.content.res.Resources;
import android.media.MediaPlayer;

public class Sound {
	Context context;
	MediaPlayer player[]=new MediaPlayer[3];

	public Sound(Context c) {
		context=c;
	}
	
	public void onResume() {
		Resources r=context.getResources();
		for (int i=0; i<player.length; i++) {
			player[i]=MediaPlayer.create(context, 
				r.getIdentifier("sound"+i, "raw", context.getPackageName()));		
		}
	}
	
	public void onPause() {
		for (int i=0; i<player.length; i++) {
			player[i].release();
			player[i]=null;
		}
	}

	public void play(int i) {
		player[i].setLooping(false);
		player[i].start();
	}
	
	public void loop(int i) {
		player[i].setLooping(true);
		player[i].start();
	}

	public void stop(int i) {
		player[i].stop();
	}
}
