From 6f471a0da76901c2071c930628ad5993940b6af6 Mon Sep 17 00:00:00 2001 From: Joshua Bahnsen Date: Fri, 22 Feb 2013 21:45:10 -0700 Subject: [PATCH] Fix some seek bar issues. Do not seek past buffer point --- .../subsonic/androidapp/activity/DownloadActivity.java | 2 ++ .../subsonic/androidapp/service/DownloadServiceImpl.java | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/net/sourceforge/subsonic/androidapp/activity/DownloadActivity.java b/src/net/sourceforge/subsonic/androidapp/activity/DownloadActivity.java index 985be05d..67832eaf 100644 --- a/src/net/sourceforge/subsonic/androidapp/activity/DownloadActivity.java +++ b/src/net/sourceforge/subsonic/androidapp/activity/DownloadActivity.java @@ -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(); diff --git a/src/net/sourceforge/subsonic/androidapp/service/DownloadServiceImpl.java b/src/net/sourceforge/subsonic/androidapp/service/DownloadServiceImpl.java index f8191a05..f1aa3aaf 100644 --- a/src/net/sourceforge/subsonic/androidapp/service/DownloadServiceImpl.java +++ b/src/net/sourceforge/subsonic/androidapp/service/DownloadServiceImpl.java @@ -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); } }