Ae galera! 8)
Estou tentando implementar uma rotina que quando o usuário clicar em um botão o sistema emita um som. Até ai tranquilo, fiz um método genérico:public static void playSound(Context c, Som s) {
MediaPlayer song = null;
if (s == Som.BUTTON) {
song = MediaPlayer.create(c, R.raw.button);
}
song.setOnCompletionListener(new OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
mp.release();
}
});
song.start();
}
public void onClick(View v) {
Util.playSound(getApplicationContext(), Util.Som.BUTTON);
Intent intent = new Intent(getApplicationContext(),Classe.class);
startActivity(intent);
}
});
01-29 21:42:12.359: I/MediaPlayer(7340): Don't send intent. msg.arg1 = 0, msg.arg2 = 0 01-29 21:49:53.364: W/MediaPlayer-JNI(11154): MediaPlayer finalized without being released
Alguém saberia me dizer o que pode ser? Porque depois de um tempo a aplicação trava, acho que é porque fica um monte de MediaPlayer carregado...
Agradeço desde já pela ajuda!