I am testing on 2 phones. In one device isPlaying() of mediaplayer always return false even when it is playing. but in other device (lg optimus gingerbread) isPlaying() returns true is it is playing else returns false.
Can anyone tell me why this is happening ? My some code depends on this isPlaying() part and i want to make it work on all devices.
public void addSoundMedia(Context context, int resId){
MediaPlayer mp = MediaPlayer.create(context, resId);
mp.setVolume(1.0f, 1.0f);
try{
mPlayerList.add(mp);
}
catch(Exception e){}
}
public void playSoundMedia(int index){
try{
mPlayerList.get(index).start();
}
catch(Exception e){}
}
public MediaPlayer getPlayer(int index){
return mPlayerList.get(index);
}
Now i am calling
mPlayer.getPlayer(currentPlayingPhraseIndex).isPlaying();
//which is now returning false. Previously i was returning true but now it always return false
And i also matched the object, this is the code scenario now:
int phraseIndexToBePlayed = getRandomInteger(0, numberOfPhrasesSelected-1, randomPhraseGen); //get random index from 0 to (size of arraylist where i added my media) -1
currentPlayingPhraseIndex = phraseIndexToBePlayed; //for later use in another function scope
mPlayer.playSoundMedia(phraseIndexToBePlayed);
i also verified if both are same media
mPlayer.getPlayer(currentPlayingPhraseIndex).equals(mPlayer.getPlayer(phraseIndexToBePlayed)); //it returns true so they are both same media
Thanks.