media player - Android MediaPlayer can't stop -
i have code fragment in brocardcastreceiver this:
if (cmd != null && cmd.equals(play_sound)) { log.i("mp", "mp has been prepared "); mp.setlooping(true); mp.start(); return; } if (cmd != null && cmd.equals(stop_sound) && mp != null) { if (mp.islooping()) { mp.setlooping(false); } mp.stop(); mp.release(); return; }
it aims control alarming or stop alarming. can make mp
run successfully, when want stop it, mp
null. how can stop mp
being changed?
try
in code
stopplaying();
and declare methode .
private void stopplaying() { if (player1 != null) { player1.stop(); player1.release(); player1 = null; } }
Comments
Post a Comment