Implemented "FF" and "Rev" Buttons

This commit is contained in:
daniel 2012-06-06 18:46:36 +02:00
parent 76f1f7054d
commit df298ba2e7
2 changed files with 31 additions and 5 deletions

View File

@ -31,6 +31,8 @@ import de.podfetcher.util.Converter;
public class MediaplayerActivity extends SherlockActivity {
private final String TAG = "MediaplayerActivity";
private static final int DEFAULT_SEEK_DELTA = 30000; // Seek-Delta to use when using FF or Rev Buttons
private PlaybackService playbackService;
private MediaPositionObserver positionObserver;
@ -214,6 +216,24 @@ public class MediaplayerActivity extends SherlockActivity {
}
}
});
butFF.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (status == PlayerStatus.PLAYING) {
playbackService.seekDelta(DEFAULT_SEEK_DELTA);
}
}
});
butRev.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (status == PlayerStatus.PLAYING) {
playbackService.seekDelta(-DEFAULT_SEEK_DELTA);
}
}
});
}

View File

@ -137,6 +137,17 @@ public class PlaybackService extends Service {
Log.d(TAG, "Notification set up");
}
/** Seek a specific position from the current position
* @param delta offset from current position (positive or negative)
* */
public void seekDelta(int delta) {
seek(player.getCurrentPosition() + delta);
}
public void seek(int i) {
Log.d(TAG, "Seeking position " + i);
player.seekTo(i);
}
public PlayerStatus getStatus() {
return status;
@ -150,9 +161,4 @@ public class PlaybackService extends Service {
return player;
}
public void seek(int i) {
Log.d(TAG, "Seeking position " + i);
player.seekTo(i);
}
}