求助!想要添加落子音效
想要使用SoundPool添加落子的音效!但是不知道该怎么实现?
我这样写貌似不行!
private SoundPool sp;
private int music;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
wuziqiPanel = (WuzhiqiPanel) findViewById(R.id.id_wuzhiqi);
playMusic();
}
private void playMusic() {
sp = new SoundPool(5, AudioManager.STREAM_SYSTEM,5);
music = sp.load(this,R.raw.yx4,1);
wuziqiPanel.setOnClickListener(listener);
}
private View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View v) {
sp.play(music, 1, 1, 0, 0, 1);
}
};