Seeking should now work again

This commit is contained in:
daniel oeh 2012-09-06 17:18:22 +02:00
parent 8a6413c6f8
commit a44bd7e255
2 changed files with 13 additions and 12 deletions

View File

@ -380,13 +380,12 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity
}
float prog;
int duration;
@Override
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
controller.onSeekBarProgressChanged(seekBar, progress, fromUser, prog,
duration, txtvPosition);
prog = controller.onSeekBarProgressChanged(seekBar, progress, fromUser,
txtvPosition);
}
@Override
@ -396,7 +395,7 @@ public abstract class MediaplayerActivity extends SherlockFragmentActivity
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
controller.onSeekBarStopTrackingTouch(seekBar, prog, duration);
controller.onSeekBarStopTrackingTouch(seekBar, prog);
}
}

View File

@ -415,14 +415,16 @@ public abstract class PlaybackController {
/**
* Should be used by classes which implement the OnSeekBarChanged interface.
*/
public void onSeekBarProgressChanged(SeekBar seekBar, int progress,
boolean fromUser, float prog, int duration, TextView txtvPosition) {
if (fromUser && PlaybackService.isRunning) {
prog = progress / ((float) seekBar.getMax());
duration = playbackService.getPlayer().getDuration();
public float onSeekBarProgressChanged(SeekBar seekBar, int progress,
boolean fromUser, TextView txtvPosition) {
if (fromUser && playbackService != null) {
float prog = progress / ((float) seekBar.getMax());
int duration = playbackService.getPlayer().getDuration();
txtvPosition.setText(Converter
.getDurationStringLong((int) (prog * duration)));
return prog;
}
return 0;
}
@ -440,9 +442,9 @@ public abstract class PlaybackController {
/**
* Should be used by classes which implement the OnSeekBarChanged interface.
*/
public void onSeekBarStopTrackingTouch(SeekBar seekBar, float prog, int duration) {
if (PlaybackService.isRunning) {
playbackService.seek((int) (prog * duration));
public void onSeekBarStopTrackingTouch(SeekBar seekBar, float prog) {
if (playbackService != null) {
playbackService.seek((int) (prog * playbackService.getPlayer().getDuration()));
setupPositionObserver();
}
}