本文整理汇总了Java中javax.media.Time类的典型用法代码示例。如果您正苦于以下问题:Java Time类的具体用法?Java Time怎么用?Java Time使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Time类属于javax.media包,在下文中一共展示了Time类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPlayerDuration
import javax.media.Time; //导入依赖的package包/类
public Time getPlayerDuration()
{
if (getState() < Realized)
{
return DURATION_UNKNOWN;
}
else if (m != null)
{
try
{
final double totalSeconds = (double) m.getDuration() / (double) m.getTimeScale();
return new Time(totalSeconds);
} catch (StdQTException e)
{
logger.log(Level.WARNING, "" + e, e);
return DURATION_UNKNOWN;
}
}
else
{
return DURATION_UNKNOWN;
}
}
示例2: getMediaTime
import javax.media.Time; //导入依赖的package包/类
public synchronized Time getMediaTime()
{
if (getState() < Realized)
{
return super.getMediaTime();
}
else if (m != null)
{
try
{
final double totalSeconds = (double) m.getTime() / (double) m.getTimeScale();
return new Time(totalSeconds);
} catch (StdQTException e)
{
logger.log(Level.WARNING, "" + e, e);
return super.getMediaTime();
}
}
else
{
return super.getMediaTime();
}
}
示例3: controllerUpdate
import javax.media.Time; //导入依赖的package包/类
/**
* This controllerUpdate function must be defined in order to
* implement a ControllerListener interface. This
* function will be called whenever there is a media event.
*
* @param event
* the media event
*/
public synchronized void controllerUpdate(ControllerEvent event) {
if( event instanceof RealizeCompleteEvent ) {
Runnable r = new Runnable() {
public void run() {
// Add Control Panel Component
playerpanel.addControlComponent();
// Add Visual Component
playerpanel.addVisualComponent();
}
};
SwingUtilities.invokeLater(r);
} else
if (event instanceof EndOfMediaEvent) {
// End of the media -- rewind
player.setMediaTime(new Time(0));
}
}
示例4: calculateMediaTime
import javax.media.Time; //导入依赖的package包/类
/**
* Calculates the media time on a started Clock based on the
assumption that the Clock is started.
*/
private synchronized Time calculateMediaTime() {
long tbCurrent = timebase.getNanoseconds();
long tbStart = timeBaseStartTime.getNanoseconds();
// If we are scheduled to start but haven't yet reached
// the scheduled start time, return the media start time
if(tbCurrent < tbStart) {
return mediaStartTime;
}
long mStart = mediaStartTime.getNanoseconds();
long mCurrent =
(long)((tbCurrent - tbStart)*rate + mStart);
return new Time(mCurrent);
}
示例5: mapToTimeBase
import javax.media.Time; //导入依赖的package包/类
/**
* Given a media time, returns the corresponding time-base
* time. Uses the current rate, the time-base start time, and
* the media start time to calculate.
*
* @param mediaStartTime
* A media time to be mapped to a time-base time.
*
* @return A time-base time.
*
* @exception ClockStoppedException
* If the clock has not started.
*/
public synchronized Time mapToTimeBase(Time t)
throws ClockStoppedException
{
if( ! isStarted ) {
throw new ClockStoppedException(
"Cannot map media time to time-base time on a Stopped Clock");
}
long mCurrent = t.getNanoseconds();
long mStart = mediaStartTime.getNanoseconds();
long tbStart = timeBaseStartTime.getNanoseconds();
return new Time((long)
(((mCurrent - mStart)/rate) + tbStart));
}
示例6: getPlayerDuration
import javax.media.Time; //导入依赖的package包/类
/**
* Get the length of the media from the MultiImageRenderer.
* The duration is taken from the MultiImageRenderer in
* nanoseconds and converted into a Time object.
*
* @return A Time object representing the duration of
* the media.
*/
public Time getPlayerDuration() {
// If the video has not yet been prefetched, then the
// MultiImageRenderer cannot calculate its duration.
// Instead, return the duration read from the header.
// (These should be the same, but mic.getDuration() will
// _always_ be correct if the frames have been set.)
if( getState() < Realized ) {
return DURATION_UNKNOWN;
} else
if( getState() < Prefetched ) {
return new Time(duration);
} else
return new Time( mic.getDuration() );
}
示例7: setStopTime
import javax.media.Time; //导入依赖的package包/类
/**
* Sets the stop time for this AbstractController. Posts a
* StopTimeChangeEvent if the stop time given is different
* than the current stop time.
*
* @param mediaStopTime
* The time at which you want the
* <tt>Clock</tt> to stop, in <i>media
* time</i>.
*
* @exception NotRealizedError
* If the Controller is not Realized.
*
* @exception ClockStartedError
* If the Controller is Started.
*/
public synchronized void setStopTime(Time mediaStopTime) {
if(currentState == Unrealized ||
currentState == Realizing)
{
throw new NotRealizedError(
"Cannot set stop time on an unrealized Controller");
}
Time oldStopTime = getStopTime();
// If the stop time has changed, post an event
if( mediaStopTime.getNanoseconds() !=
oldStopTime.getNanoseconds() )
{
// Set in superclass
super.setStopTime(mediaStopTime);
// Post event
postEvent(
new StopTimeChangeEvent(this, mediaStopTime) );
}
}
示例8: blockUntilStart
import javax.media.Time; //导入依赖的package包/类
/**
* For a given time-base start time, block until the
* AbstractController should be started. For a given time-
* base start time (t), this method will get the
* AbstractController's start latency (l) and block until (t
* - l). This method is useful for implementations of
* doSyncStart().
* <p>
* If the time-base time (t - l) has already passed, return
* immediately.
*/
public void blockUntilStart(Time t) {
// Calculate start latency. If unknown, asssume zero.
Time latencyTime = getStartLatency();
long latency;
if( latencyTime == LATENCY_UNKNOWN ) {
latency = 0;
} else {
latency = latencyTime.getNanoseconds();
}
long start = t.getNanoseconds();
long now = getTimeBase().getNanoseconds();
long delay = (start - latency - now)/1000000;
// Wait for the syncTime
if( delay > 0 ) {
try {
Thread.sleep(delay);
} catch(InterruptedException e) {}
}
}
示例9: getTracks
import javax.media.Time; //导入依赖的package包/类
public Track[] getTracks() throws IOException, BadHeaderException {
if (tracks[0] != null)
return tracks;
stream = (PullSourceStream) streams[0];
readHeader();
bufferSize = bytesPerSecond;
tracks[0] = new GsmTrack((AudioFormat) format,
/*enabled=*/ true,
new Time(0),
numBuffers,
bufferSize,
minLocation,
maxLocation
);
return tracks;
}
示例10: BasicTrack
import javax.media.Time; //导入依赖的package包/类
/**
* Note to implementors who want to use this class.
* If the maxLocation is not known, then
* specify Long.MAX_VALUE for this parameter
*/
public BasicTrack(GsmParser parser,
Format format, boolean enabled,
Time duration, Time startTime,
int numBuffers, int dataSize,
PullSourceStream stream,
long minLocation, long maxLocation) {
this.parser = parser;
this.format = format;
this.enabled = enabled;
this.duration = duration;
this.startTime = startTime;
this.numBuffers = numBuffers;
this.dataSize = dataSize;
this.stream = stream;
this.minLocation = minLocation;
this.maxLocation = maxLocation;
maxStartLocation = maxLocation - dataSize;
}
示例11: controllerUpdate
import javax.media.Time; //导入依赖的package包/类
/**
* Controller Listener.
*/
public void controllerUpdate(ControllerEvent evt) {
if (evt instanceof ConfigureCompleteEvent ||
evt instanceof RealizeCompleteEvent ||
evt instanceof PrefetchCompleteEvent) {
synchronized (waitSync) {
stateTransitionOK = true;
waitSync.notifyAll();
}
} else if (evt instanceof ResourceUnavailableEvent) {
synchronized (waitSync) {
stateTransitionOK = false;
waitSync.notifyAll();
}
} else if (evt instanceof EndOfMediaEvent) {
p.setMediaTime(new Time(0));
//p.start();
//p.close();
//System.exit(0);
} else if (evt instanceof SizeChangeEvent) {
}
}
示例12: doPlayerSyncStart
import javax.media.Time; //导入依赖的package包/类
public boolean doPlayerSyncStart(Time t)
{
logger.info("Handler.doPlayerSyncStart (sec): " + t.getSeconds());
try {
registerStopTriggerNotification();
m.start();
} catch (QTException e) {
logger.log(Level.WARNING, "" + e, e);
return false;
}
return true;
}
示例13: getDuration
import javax.media.Time; //导入依赖的package包/类
@Override
public Time getDuration()
{
synchronized (QT_SYNC_OBJ)
{
if (qtSnapper.getDuration() <= 0 || qtSnapper.getTimeScale() <= 0)
return Duration.DURATION_UNKNOWN;
return new Time((qtSnapper.getDuration() * 1000000000L) / qtSnapper.getTimeScale());
}
}
示例14: doPlayerSetMediaTime
import javax.media.Time; //导入依赖的package包/类
@Override
public void doPlayerSetMediaTime(Time t)
{
logger.info("Handler.doPlayerSetMediaTime " + t.getNanoseconds());
// TODO: untested since getPosition is always returning 0, the FMJStudio
// app does not allow us to seek.
playbin.setPosition(new org.gstreamer.Time(t.getNanoseconds()));
}
示例15: doPlayerSyncStart
import javax.media.Time; //导入依赖的package包/类
@Override
public boolean doPlayerSyncStart(Time t)
{
logger.info("Handler.doPlayerSyncStart" + t);
if (!playbin.isPlaying())
{
playbin.play();
}
return true;
}