글쎄, 내 문제는 약 12 개의 소리와 같은 수의 이미지가 있다는 것입니다. 내가하고 싶은 것은 해당 이미지로 사운드를 재생하는 것입니다. 사운드가 끝나면 모든 사운드가 재생 될 때까지 다음 이미지로 다음 사운드를 재생하는 등의 작업을 반복합니다. 시각.안드로이드에서 순차적으로 여러 사운드 재생
모두가 짧은 소리이므로 SoundPool을 사용하고 있습니다.
아무도 나를 도와 줄 수 있습니까?. 미리 감사드립니다. 여기
은 ... 코드가, 미안, 내가 포함 깜빡입니다String[] flauta = new String[]{"flauta_do","flauta_re","flauta_mi","flauta_fa","flauta_sol","flauta_la","flauta_si","flauta_do_agudo","flauta_re_agudo","flauta_mi_agudo","flauta_fa_agudo","flauta_sol_agudo"};
String[] pentagrama = new String[]{"pentagrama_do","pentagrama_re","pentagrama_mi","pentagrama_fa","pentagrama_sol","pentagrama_la","pentagrama_si","pentagrama_do_agudo","pentagrama_re_agudo","pentagrama_mi_agudo","pentagrama_fa_agudo","pentagrama_sol_agudo"};
String[] nota = new String[]{"Do","Re","Mi","Fa","Sol","La","Si","Do alto","Re alto","Mi alto","Fa alto","Sol alto"};
String[] sonido = new String[]{"sonido_do","sonido_re","sonido_mi","sonido_fa","sonido_sol","sonido_la","sonido_si","sonido_do_agudo","sonido_re_agudo","sonido_mi_agudo","sonido_fa_agudo","sonido_sol_agudo"};
private SoundPool sPool;
ImageView flautaIV;
ImageView pentagramaIV;
TextView notaTV;
int resID = 0;
String recurso = "";
int sonidoNota = 0;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_repasar);
flautaIV = (ImageView)findViewById(R.id.flautaIV);
pentagramaIV = (ImageView)findViewById(R.id.pentagramaIV);
notaTV = (TextView)findViewById(R.id.notaTV);
sPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
for(int i = 0; i < flauta.length; i++)
{
recurso = flauta[i];
resID = getResources().getIdentifier(recurso, "drawable", getPackageName());
flautaIV.setImageResource(resID);
recurso = pentagrama[i];
resID = getResources().getIdentifier(recurso, "drawable", getPackageName());
pentagramaIV.setImageResource(resID);
notaTV.setText(nota[i]);
recurso = sonido[i];
resID = getResources().getIdentifier(recurso, "raw", getPackageName());
sonidoNota = sPool.load(this, resID, 1);
sPool.play(sonidoNota, (float)1.0, (float)1.0, 1, 0, 1f);
}
}
코드를 표시하십시오 – joao2fast4u