1
0
mirror of https://github.com/ultrasonic/ultrasonic synced 2025-02-07 12:33:20 +01:00

Fix some seek bar issues. Do not seek past buffer point

This commit is contained in:
Joshua Bahnsen 2013-02-22 21:45:10 -07:00
parent a353d89b67
commit 6f471a0da7
2 changed files with 8 additions and 3 deletions

View File

@ -696,11 +696,13 @@ public class DownloadActivity extends SubsonicTabActivity implements OnGestureLi
durationTextView.setText(Util.formatDuration(millisTotal / 1000));
progressBar.setMax(millisTotal == 0 ? 100 : millisTotal); // Work-around for apparent bug.
progressBar.setProgress(millisPlayed);
progressBar.setEnabled(currentPlaying.isCompleteFileAvailable() || getDownloadService().isJukeboxEnabled());
} else {
positionTextView.setText("0:00");
durationTextView.setText("-:--");
progressBar.setProgress(0);
progressBar.setMax(0);
progressBar.setEnabled(false);
}
PlayerState playerState = getDownloadService().getPlayerState();

View File

@ -107,6 +107,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
private StreamProxy proxy;
private static MusicDirectory.Entry currentSong;
private RemoteControlClient remoteControlClient;
private int secondaryProgress = -1;
static {
try {
@ -518,7 +519,8 @@ public class DownloadServiceImpl extends Service implements DownloadService {
if (jukeboxEnabled) {
jukeboxService.skip(getCurrentPlayingIndex(), position / 1000);
} else {
mediaPlayer.seekTo(position);
if (secondaryProgress == -1 || secondaryProgress >= position)
mediaPlayer.seekTo(position);
}
} catch (Exception x) {
handleError(x);
@ -829,8 +831,9 @@ public class DownloadServiceImpl extends Service implements DownloadService {
mediaPlayer.setOnCompletionListener(null);
mediaPlayer.setOnBufferingUpdateListener(null);
mediaPlayer.reset();
secondaryProgress = -1; // Ensure seeking in non StreamProxy playback works
setPlayerState(IDLE);
mediaPlayer.setOnBufferingUpdateListener(new MediaPlayer.OnBufferingUpdateListener() {
@Override
public void onBufferingUpdate(MediaPlayer mp, int percent) {
@ -838,7 +841,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
MusicDirectory.Entry song = downloadFile.getSong();
if (progressBar != null && song.getTranscodedContentType() == null && Util.getMaxBitrate(getApplicationContext()) == 0) {
int secondaryProgress = (int) (((double)percent / (double)100) * progressBar.getMax());
secondaryProgress = (int) (((double)percent / (double)100) * progressBar.getMax());
DownloadActivity.getProgressBar().setSecondaryProgress(secondaryProgress);
}
}