I have a method test() inside my onPrepared(Mediaplayer mp) method. The test() spawns a runnable and does the following :
public void test() {
Runnable playerValues = new Runnable() {
@Override
public void run() {
System.out
.println("Player.testPla开发者_如何学编程ying() --> Get Duration : "
+ vv.getDuration());
System.out
.println("Player.testPlaying() --> Total Bytes Read : "
+ Download.totalBytesRead);
System.out
.println("Player.testPlaying() --> Current Position : "
+ vv.getCurrentPosition());
handler.postDelayed(this, 1000);
}
};
handler.postDelayed(playerValues, 1000);
}
At OnCompletion method of the player i want to stop this Runnable. How can i do that?
Try handler.removeCallbacks(playerValues). (I think you'll want to declare playerValues as a field for that to work, because otherwise handler won't have the scope to see it.)
精彩评论