public synchronized void setTime(long granulePosition) throws IOException {

      int page=0;
      for(page=0; page<granulePositions.size(); page++) {
         Long gp=(Long)granulePositions.get(page);
         if(gp.longValue()>granulePosition) {
            break;
         }
      }

      pageIndex=page;
      currentPage=source.getOggPage(((Integer)pageNumberMapping.get(pageIndex++)).intValue());
      currentSegmentIndex=0;
      int segmentLength=0;
      do {
         if(currentSegmentIndex>=currentPage.getSegmentOffsets().length) {
            currentSegmentIndex=0;
            if(pageIndex>=pageNumberMapping.size()) {
               throw new EndOfOggStreamException();
            }
            currentPage=source.getOggPage(((Integer)pageNumberMapping.get(pageIndex++)).intValue());
         }
         segmentLength=currentPage.getSegmentLengths()[currentSegmentIndex];
         currentSegmentIndex++;
      } while(segmentLength==255);
   }