I am trying to use onCompletion method to rest, release and nullify the MediaPlayer.
I am doing this as follows:
@Override
public void onClick(View v) {
if (player1 == null) {
player1 = new MediaPlayer();
player1.setVolume(10, 10);
player1.setOnCompletionListener(this);
}
switch (v.getId()) {
.
.
.
public void onCompletion(MediaPlayer player1) {
player1.reset();
player1.release();
player1 = null;
.
.
.
However, when I try to debug in Eclips, I see that player1 is not “null”. Can somebody please let me know how shall I pass player1 so that I can make it “null”.
Thank you very much for the help.
TJ
try to use
this.player1=nullas in onCompletion event you are setting null to local variable, while in onClick event you are checking member variable, it is not visible currently in the above code but my guess.