Skip to content

Instantly share code, notes, and snippets.

@codingwithsara
Created November 27, 2018 01:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingwithsara/403ca9882330236ac8b0adc3069788af to your computer and use it in GitHub Desktop.
Save codingwithsara/403ca9882330236ac8b0adc3069788af to your computer and use it in GitHub Desktop.
Android MusicPlayer 4
mp.seekTo(0);
mp.setVolume(0.5f, 0.5f);
totalTime = mp.getDuration();
// 再生位置
positionBar = findViewById(R.id.positionBar);
positionBar.setMax(totalTime);
positionBar.setOnSeekBarChangeListener(
new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (fromUser) {
mp.seekTo(progress);
positionBar.setProgress(progress);
}
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
}
);
// 音量調節
volumeBar = findViewById(R.id.volumeBar);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment