Audio is playing twice in Android Media Player -
in application i'm having method responsible playing file placed under raw directory. when ever call function in onresume()
method, sound played twice. have googled , tried different solutions. checking mediaplayer.isplaying()
, stopping mediaplayer
instance still didn't help.
private void englishsound(){ if(mediaplayer1!=null){ if(mediaplayer1.isplaying()){ mediaplayer1.stop(); } mediaplayer1.reset(); mediaplayer1.release(); } mediaplayer1 = mediaplayer.create(this, r.raw.p012); mediaplayer1.start(); } public void onresume() { super.onresume(); englishsound(); }
and englishsound()
called no else in whole activity. have tried debugging never enters if block containing isplaying()
.
try release onpause()
public void onpause() { super.onpause(); if(mediaplayer1 != null) mediaplayer1.release(); }
Comments
Post a Comment