0
이제 게임 응용 프로그램을 개발하고 Google 게임의 모든 게임에서 소리를 켜거나 끌 수있는 토글 버튼이 있습니다.내 게임 앱에서 사운드를 사용 중지하는 방법은 무엇인가요?
한 단계로 게임의 모든 소리를 비활성화하는 데 사용할 수있는 기술이 있습니까? 아니면 별도로 모든 사운드를 비활성화해야합니까? 내가 연주를 위해 MediaPlayer를를 사용
는
private int playSound(int file) {
int duration = 1000;
sound = new MediaPlayer();
AssetFileDescriptor fd = getResources().openRawResourceFd(file);
try {
sound.setDataSource(fd.getFileDescriptor(), fd.getStartOffset(), fd.getLength());
sound.prepare();
sound.start();
sound.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
// Do the work after completion of audio
Toast.makeText(GameActivity.this, "good", Toast.LENGTH_SHORT).show();
mp.release();
}
});
duration = sound.getDuration();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return duration;
}
어떤 기본 버튼 소리 같은 다른 소리에 대한 시도 소리? –