-
-
Save codeforfun-jp/280197b074ae4d175a301b5b9a43bb38 to your computer and use it in GitHub Desktop.
CTB 11-1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package jp.codeforfun.catchtheball; | |
import android.content.Context; | |
import android.media.AudioAttributes; | |
import android.media.AudioManager; | |
import android.media.SoundPool; | |
public class SoundPlayer { | |
private static SoundPool soundPool; | |
private static int hitSound; | |
private static int overSound; | |
public SoundPlayer(Context context) { | |
soundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0); | |
hitSound = soundPool.load(context, R.raw.hit, 1); | |
overSound = soundPool.load(context, R.raw.over, 1); | |
} | |
public void playHitSound() { | |
soundPool.play(hitSound, 1.0f, 1.0f, 1, 0, 1.0f); | |
} | |
public void playOverSound() { | |
soundPool.play(overSound, 1.0f, 1.0f, 1, 0, 1.0f); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment