Methods Summary |
---|
public long | getMediaNanoseconds()Get the current media time in nanoseconds.
if (getState() == STOPPED) {
return mediaTime;
}
long now = master.getNanoseconds();
if (now > startTime) {
// The media has been playing for a while.
long t = (long)((double)(now - startTime) * rate) + mediaTime;
if (mediaLength != -1 && t > mediaStart + mediaLength)
return mediaStart + mediaLength;
else
return t;
} else {
// We haven't reached the scheduled start time yet.
return mediaTime;
}
|
public javax.media.Time | getMediaTime()Return the current media time.
return new Time(getMediaNanoseconds());
|
public float | getRate()Get the current presentation speed.
return rate;
|
public int | getState()Return the current state of the clock in either started or stopped
state.
// A start time has not been set.
if (startTime == Long.MAX_VALUE)
return STOPPED;
// A stop time has not been set.
if (stopTime == Long.MAX_VALUE)
return STARTED;
// The tricky case is when the clocked has started and
// the media has reached the scheduled stop time. In that
// case, the clock is considered stopped.
// COMMENTED OUT BY BABU
// long now = master.getNanoseconds();
// if (now > startTime) {
// // The media has already been playing for some time.
// long curMediaTime = (long)((now - startTime) * rate) + mediaTime;
// if ((rate > 0 && curMediaTime >= stopTime) ||
// (rate < 0 && curMediaTime <= stopTime)) {
// // We have gone past the scheduled stop time.
// // We are in the stop state.
// System.out.println(this + ": BasicClock getState() SIDEEFFECT");
// mediaTime = validateTime(stopTime);
// startTime = Long.MAX_VALUE;
// return STOPPED;
// }
// }
// In all other cases, the clock has already been started.
return STARTED;
|
public javax.media.Time | getStopTime()Return the preset stop time.
return new Time(stopTime);
|
public javax.media.Time | getSyncTime()Return the Sync Time.
Not yet implementated.
return new Time(0);
|
public javax.media.TimeBase | getTimeBase()Get the Time Base that the clock is currently using.
return master;
|
public javax.media.Time | mapToTimeBase(javax.media.Time t)Map the the given media-time to time-base-time.
if (getState() == STOPPED) {
ClockStoppedException e = new ClockStoppedException();
Log.dumpStack(e);
throw e;
}
return new Time((long)((t.getNanoseconds() - mediaTime)/rate) + startTime);
|
protected void | setMediaLength(long t)Set the upper bound of the media time.
mediaLength = t;
|
protected void | setMediaStart(long t)Set the lower bound of the media time.
mediaStart = t;
|
public void | setMediaTime(javax.media.Time now)Set the media time. This will be the media presented at the
clock's start time.
if (getState() == STARTED) {
throwError(new ClockStartedError("setMediaTime() cannot be used on a started clock."));
}
long t = now.getNanoseconds();
if (t < mediaStart)
mediaTime = mediaStart;
else if (mediaLength != -1 && t > mediaStart + mediaLength)
mediaTime = mediaStart + mediaLength;
else
mediaTime = t;
|
public float | setRate(float factor)Set the rate of presentation: 1.0: normal, 2.0: twice the speed.
-2.0: twice the speed in reverse.
if (getState() == STARTED) {
throwError(new ClockStartedError("setRate() cannot be used on a started clock."));
}
rate = factor;
return rate;
|
public void | setStopTime(javax.media.Time t)Preset a stop time in media time.
if (getState() == STARTED && stopTime != Long.MAX_VALUE) {
throwError(new StopTimeSetError("setStopTime() may be set only once on a Started Clock"));
}
stopTime = t.getNanoseconds();
|
public void | setTimeBase(javax.media.TimeBase master)Set a time base on the clock.
All media-time to time-base-time will be computed with the
given time base.
if (getState() == STARTED) {
throwError(new ClockStartedError("setTimeBase cannot be used on a started clock."));
}
if (master == null) {
if (!(this.master instanceof SystemTimeBase))
this.master = new SystemTimeBase();
} else
this.master = master;
|
public void | stop()Stop the clock immediately.
if (getState() == STOPPED) {
// It's already stopped. No-op.
return;
}
// It's a change of state, so we'll mark the mediaTime.
mediaTime = getMediaNanoseconds();
// Reset the start time.
startTime = Long.MAX_VALUE;
|
public void | syncStart(javax.media.Time tbt)Start the clock with the given time-base-time
if (getState() == STARTED) {
throwError(new ClockStartedError("syncStart() cannot be used on an already started clock."));
}
// If the given start time is already later than now. We'll reset
// the clock start time to now.
if (master.getNanoseconds() > tbt.getNanoseconds())
startTime = master.getNanoseconds();
else
startTime = tbt.getNanoseconds();
|
protected void | throwError(java.lang.Error e)
Log.dumpStack(e);
throw e;
|