I am playing some wav file and after while i want to stop it.
I am using singleton like
private static playSound instance = null;
public static synchronized playSound getInstance(Context context) {
if(null == instance) {
instance = new playSound(context, "", 1);
}
return instance;
}
and i am calling
public void stopAudio() {
try{
myplayer.stop();
myplayer.release();
} catch(Exception e){
Log.e(TAG, "Exception caught:\n" + e.getMessage() +"\n" + e.getStackTrace());
}
}
instance is not null so i think this should work because is the same instance…
but i get:
MediaPlayer: stop called in state 1
You need to check first is it playing or not ?? If it is playing your stop method should work.
E.g :