Commit 93732e30 authored by Ben Schwartz's avatar Ben Schwartz Committed by Maik Merten
Browse files

Add a new option, ignoreBasetime, so that users can force the initial time to...

Add a new option, ignoreBasetime, so that users can force the initial time to be 0:00:00 even if the stream starts at a high granulepos.
parent 566e2789
......@@ -151,6 +151,13 @@ parameters:
square pixels. true or false.
Defaults to false
ignoreBasetime: boolean
Ignore the ogg file's basetime (initial granule or granpos) when
displaying times in the seek bar. Instead, for display purposes,
always treat the first sample as occurring at time zero.
true or false.
Defaults to false
video: boolean
Use video. When not using video, this property will not create
resources to play a video stream. true or false.
......
......@@ -41,6 +41,7 @@ public class Cortado extends Applet implements Runnable, MouseMotionListener,
private boolean showSubtitles;
private boolean keepAspect;
private boolean ignoreAspect;
private boolean ignoreBasetime;
private boolean autoPlay;
private int bufferSize;
private String userId;
......@@ -123,6 +124,8 @@ public class Cortado extends Applet implements Runnable, MouseMotionListener,
"Use aspect ratio of video (default true)"},
{"ignoreAspect", "boolean",
"Ignore the aspect ratio as signalled by the video, always assume square pixels (default false)"},
{"ignoreBasetime", "boolean", "Ignore the ogg file's basetime, and instead always display time as " +
"starting at zero (default false)"},
{"bufferSize", "int",
"The size of the prebuffer in Kbytes (default 100)"},
{"bufferLow", "int", "Percent of empty buffer (default 10)"},
......@@ -250,6 +253,7 @@ public class Cortado extends Applet implements Runnable, MouseMotionListener,
showSubtitles = getBoolParam("showSubtitles", true);
keepAspect = getBoolParam("keepAspect", true);
ignoreAspect = getBoolParam("ignoreAspect", false);
ignoreBasetime = getBoolParam("ignoreBasetime", false);
bufferSize = getIntParam("bufferSize", 200);
bufferLow = getIntParam("bufferLow", 10);
bufferHigh = getIntParam("bufferHigh", 70);
......@@ -303,6 +307,7 @@ public class Cortado extends Applet implements Runnable, MouseMotionListener,
status.setShowSpeaker(showSpeaker);
status.setShowSubtitles(showSubtitles);
status.setHaveAudio(audio);
status.setIgnoreBasetime(ignoreBasetime);
status.setHaveSubtitles(false); // by default
status.setHavePercent(true);
/* assume live stream unless specified */
......
......@@ -48,6 +48,7 @@ public class Status extends Component implements MouseListener,
private boolean showSpeaker;
private boolean showSubtitles;
private boolean clearedScreen;
private boolean ignoreBasetime = false;
private static final int NONE = -1;
private static final int BUTTON1 = 0;
......@@ -268,14 +269,21 @@ public class Status extends Component implements MouseListener,
}
private void paintTime(Graphics g) {
long hour, min, sec;
long t=time, hour, min, sec;
int end;
if (time < 0)
// time is an integer, but startTime is a double. Subtracting them
// will leave some remainder (less than one second) uncorrected. I see
// no way to resolve that without changing time to be a double as well.
// The remainder means that although the initial time will be 0, it may
// change to 1 in less than a second.
if (ignoreBasetime)
t -= (long)startTime;
if (t < 0)
return;
sec = time % 60;
min = time / 60;
sec = t % 60;
min = t / 60;
hour = min / 60;
min %= 60;
......@@ -423,6 +431,10 @@ public class Status extends Component implements MouseListener,
}
}
public void setIgnoreBasetime(boolean ignore) {
ignoreBasetime = ignore;
}
public void setStartTime(double seconds) {
startTime = seconds >= 0 ? seconds : 0;
component.repaint();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment