statehelper.java~1~

来自「这是各类实用工具的源码100例」· JAVA~1~ 代码 · 共 77 行

JAVA~1~
77
字号
package jsounddemo2;import javax.media.ControllerListener;import javax.media.ControllerEvent;import javax.media.*;import javax.media.control.*;import javax.media.datasink.*;import javax.media.format.*;import javax.media.protocol.*;public class StateHelper implements ControllerListener {  Player player = null;  boolean configured = false;  boolean realized = false;  boolean prefetched = false;  boolean failed = false;  boolean closed = false;  public StateHelper(Player player) {    this.player=player;    this.player.addControllerListener(this);  }  public boolean configure(int timeOutMillis){    long startTime = System.currentTimeMillis();    synchronized(this){      if (player instanceof Processor){        ((Processor)player).configure();      }else{        return false;      }      while (!configured && !failed){        try{          wait(timeOutMillis);        }catch(InterruptedException err){        }        if (System.currentTimeMillis()-startTime>timeOutMillis)          break;      }    }    return this.configured;  }  public boolean realize(int timeOutMillis){    long startTime = System.currentTimeMillis();    synchronized(this){      player.realize();      while(!realized && !failed){        try{          wait(timeOutMillis);        }catch(InterruptedException err){        }        if      }    }  }  public void controllerUpdate(ControllerEvent parm1) {    /**@todo Implement this javax.media.ControllerListener method*/    //throw new java.lang.UnsupportedOperationException("Method controllerUpdate() not yet implemented.");  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?