1
0
mirror of https://github.com/ultrasonic/ultrasonic synced 2025-02-12 01:30:46 +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)); durationTextView.setText(Util.formatDuration(millisTotal / 1000));
progressBar.setMax(millisTotal == 0 ? 100 : millisTotal); // Work-around for apparent bug. progressBar.setMax(millisTotal == 0 ? 100 : millisTotal); // Work-around for apparent bug.
progressBar.setProgress(millisPlayed); progressBar.setProgress(millisPlayed);
progressBar.setEnabled(currentPlaying.isCompleteFileAvailable() || getDownloadService().isJukeboxEnabled());
} else { } else {
positionTextView.setText("0:00"); positionTextView.setText("0:00");
durationTextView.setText("-:--"); durationTextView.setText("-:--");
progressBar.setProgress(0); progressBar.setProgress(0);
progressBar.setMax(0); progressBar.setMax(0);
progressBar.setEnabled(false);
} }
PlayerState playerState = getDownloadService().getPlayerState(); PlayerState playerState = getDownloadService().getPlayerState();

View File

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