-
-
Save codingwithsara/a0400a0e7138a034985990a78c511d32 to your computer and use it in GitHub Desktop.
Android MusicPlayer 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Handler handler = new Handler() { | |
@Override | |
public void handleMessage(Message msg) { | |
int currentPosition = msg.what; | |
// 再生位置を更新 | |
positionBar.setProgress(currentPosition); | |
// 経過時間ラベル更新 | |
String elapsedTime = createTimeLabel(currentPosition); | |
elapsedTimeLabel.setText(elapsedTime); | |
// 残り時間ラベル更新 | |
String remainingTime = createTimeLabel(totalTime-currentPosition); | |
remainingTimeLabel.setText("- " + remainingTime); | |
} | |
}; | |
public String createTimeLabel(int time) { | |
String timeLabel = ""; | |
int min = time / 1000 / 60; | |
int sec = time / 1000 % 60; | |
timeLabel = min + ":"; | |
if (sec < 10) timeLabel += "0"; | |
timeLabel += sec; | |
return timeLabel; | |
} | |
public void playBtnClick(View view) { | |
if (!mp.isPlaying()) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment