protected long startTime;
protected long timeOffset;
protected long seekOffset;
- protected boolean seekBackwards;
+ protected boolean farSeeking;
protected boolean paused;
protected boolean isQuitting = false;
protected double playbackSpeed;
startTime = System.currentTimeMillis() - timeOffset;
this.timeOffset = timeOffset;
seekOffset = -1;
- seekBackwards = false;
+ farSeeking = false;
paused = false;
playbackSpeed = 1.0;
startTime = -1;
timeOffset = 0;
seekOffset = -1;
- seekBackwards = false;
+ farSeeking = false;
paused = false;
playbackSpeed = 1.0;
public synchronized void setTimeOffset(long pos) {
seekOffset = (long)(pos / playbackSpeed);
- if (seekOffset < timeOffset) {
- seekBackwards = true;
+ long minJumpForwardOffset = timeOffset + (long)(10000 / playbackSpeed);
+ if (seekOffset < timeOffset || seekOffset > minJumpForwardOffset) {
+ farSeeking = true;
}
notify();
}
// Methods for internal use.
//
private synchronized boolean fillBuffer() throws IOException {
- // The reading thread should be interrupted on backward seeking.
- if (seekBackwards)
- throw new EOFException("[REWIND]");
+ // The reading thread should be interrupted on far seeking.
+ if (farSeeking)
+ throw new EOFException("[JUMP]");
// Just wait unless we are performing playback OR seeking.
waitWhilePaused();
vc.processNormalProtocol();
} catch (EOFException e) {
long newTimeOffset;
- if (e.getMessage() != null && e.getMessage().equals("[REWIND]")) {
- // A special type of EOFException allowing us to seek backwards.
+ if (e.getMessage() != null && e.getMessage().equals("[JUMP]")) {
+ // A special type of EOFException allowing us to close FBS stream
+ // and then re-open it for jumping to a different time offset.
newTimeOffset = fbs.getSeekOffset();
autoPlay = !fbs.isPaused();
} else {