Package javax.media

Examples of javax.media.Time


        {
            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
View Full Code Here


            throw new NotRealizedError(
                "Cannot set media time on an Unrealized Controller");
        }

        long nano = t.getNanoseconds();
        Time duration = getDuration();

        //  Enforce upper bound on start time
        if( duration != DURATION_UNKNOWN &&
            duration != DURATION_UNBOUNDED )
        {
            long limit = duration.getNanoseconds();
            if( nano > limit ) {
                t = new Time(limit);
            }
        }

        //  Set the media time
        super.setMediaTime(t);
View Full Code Here

     *
     * @return     The current media time
     */
    @Override
  public synchronized Time getMediaTime() {
        Time mediaTime = super.getMediaTime();
        Time duration = getDuration();

        //  Compare media time with duration
        if( duration != DURATION_UNKNOWN &&
            duration != DURATION_UNBOUNDED &&
            mediaTime.getNanoseconds() > duration.getNanoseconds() )
        {
            return duration;
        }

        return mediaTime;
View Full Code Here

        //  Set the state and post event
        setState( Started );
        postStartEvent();

        //  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();

        //  If the start time is in the past, change it to now
        if(now  + latency > start) t = new Time(now + latency);

        //  Start the clock
        super.syncStart(t);

        boolean result;
View Full Code Here

     * 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;
View Full Code Here

         else
         {
           final long durationNanos = playbin.getDuration().longValue();
           if (durationNanos <= 0// TODO: why are we getting 0?
             return DURATION_UNKNOWN; 
           return new Time(durationNanos);
         }
  }
View Full Code Here

    {
      return super.getMediaTime();
    }
         else
         {
           return new Time(playbin.getPosition().longValue());
         }
  }
View Full Code Here

 
  @Override
  public Time getPlayerStartLatency()
  {
    return new Time(0);
  }
View Full Code Here

      * @return     javax.media.Time object representing the
      *             maximum startup latency across all the input
      *             Controllers.
      */
    public static Time getMaximumLatency(Controller[] controllers) {
        Time    maxLatency = new Time(0.0);
        Time    thisTime;
        double  maxSeconds = 0.0;

        for (int i = 0; i < controllers.length; i++) {
            if (controllers[i].getState() < Controller.Realized ||
               (thisTime = controllers[i].getStartLatency())
                    == Controller.LATENCY_UNKNOWN)
            {
                continue;
            }

            double thisSeconds = thisTime.getSeconds();
            if (thisSeconds > maxSeconds)
                maxLatency = thisTime;
        }
        return maxLatency;
    }
View Full Code Here

  init()// KAL: added to handle case where controller starts before our controllerUpdate handler gets registered.
  }
    }

    private void init() {
  Time d = getController().getDuration();
  // If duration is unknown or unbounded, slider
        // will not be operational.
  boolean flg =
          d != Duration.DURATION_UNBOUNDED &&
           d != Duration.DURATION_UNKNOWN;

  // We have some know duration, is it zero?
  if (flg) {
      duration = d.getNanoseconds();
      flg = (duration != 0L);
  }
  setOperational(flg);
  // Duration is known and non-zero, all is well...
  if (flg) {
      // Setup timer
      controlTimer = new SourcedTimer(this, TIMER_TICK);
        controlTimer.addSourcedTimerListener(this);

      Time mTime = getController().getMediaTime();
      long mediaTime = mTime.getNanoseconds();

      setValue(mediaTime);
     
      if (getController().getState() == Controller.Started)
        controlTimer.start()// this handles the case where it is already started before we get here, in which case controllerUpdate will never get called with the initial state
View Full Code Here

TOP

Related Classes of javax.media.Time

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.