Skip to content

Commit d85c2bc

Browse files
committed
Changes
1 parent 7a9fb84 commit d85c2bc

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

fileViewer/src/main/java/io/genemoz/fileviewer/audioView/CustomAudioPlayer.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,27 @@ private void init(Context context) {
6363
@Override
6464
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
6565
if (mediaPlayer != null && fromUser) {
66-
int duration = mediaPlayer.getDuration();
67-
int seek = (int) ((float) progress / 100.0 * (float) duration);
68-
mediaPlayer.seekTo(seek);
66+
mediaPlayer.seekTo(progress);
67+
elapsedTimeLabel.setText(formatTime(progress));
68+
remainingTimeLabel.setText(formatTime(mediaPlayer.getDuration() - progress));
6969
}
7070
}
7171

7272
@Override
7373
public void onStartTrackingTouch(SeekBar seekBar) {
74+
if (mediaPlayer != null && mediaPlayer.isPlaying()) {
75+
mediaPlayer.pause();
76+
}
7477
}
7578

7679
@Override
7780
public void onStopTrackingTouch(SeekBar seekBar) {
81+
if (mediaPlayer != null) {
82+
mediaPlayer.start();
83+
}
7884
}
7985
});
86+
8087
}
8188

8289
public void setDataSource(String path) throws IOException {

0 commit comments

Comments
 (0)