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

    boolean looping= true;
   
    public void controllerUpdate( ControllerEvent ce) {
  System.out.println( ce);
  if( ce instanceof DurationUpdateEvent) {
      Time duration= ((DurationUpdateEvent) ce).getDuration();
           
      System.out.println( "duration: " + duration.getSeconds());
  } else ifce instanceof EndOfMediaEvent) {
      System.out.println( "END OF MEDIA - looping=" + looping);
      if( looping) {
          processor.setMediaTime( new Time( 0));
    processor.start();
      }
  }
    }
View Full Code Here

     * time, and the rate.
     *
     * @return     The current media time
     */
    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

    }

  // Start player "now"
    public void execute() {
  long now = player.getTimeBase().getNanoseconds();
  player.syncStart(new Time(now));
    }
View Full Code Here

            //  Set the initial rate
            setRate(1);

            //  Set the initial media time
            setMediaTime( new Time(0) );

        } else {

            //  The realize was unsuccessful
            //  Rely on the Controller to post the
View Full Code Here

            //  Set the current state and post event
            setState( Prefetched );
            postPrefetchCompleteEvent();

            //  Set the initial media time
            setMediaTime( new Time(0) );

        } else {

            //  The prefetch was unsuccessful.
            //  Rely on the Controller to post the
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);

        //  Do the actual syncStarting
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

  setOperational(false);
  getController().addControllerListener(this);
    }

    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);
        }
    }
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.