@SuppressWarnings("static-access")
	public void read(Buffer buf) throws IOException {
      
      // Check if we've finished all the frames.
      if (nextImage >= images.size()) {
        // We are done.  Set EndOfMedia.
        System.err.println("Done reading all images.");
        buf.setEOM(true);
        buf.setOffset(0);
        buf.setLength(0);
        ended = true;
        return;
      }
      
      String imageFile = (String)images.get(nextImage);
      nextImage++;
      
      //System.err.println("  - reading image file: " + imageFile);
      
      // Open a random access file for the next image. 
      RandomAccessFile raFile;
      raFile = new RandomAccessFile(imageFile, "r");
      
      byte data[] = null;
      
      // Check the input buffer type & size.
      
      if (buf.getData() instanceof byte[])
        data = (byte[])buf.getData();
      
      // Check to see the given buffer is big enough for the frame.
      if (data == null || data.length < raFile.length()) {
        data = new byte[(int)raFile.length()];
        buf.setData(data);
      }
      
      // Read the entire JPEG image from the file.
      raFile.readFully(data, 0, (int)raFile.length());
      
      //System.err.println("    read " + raFile.length() + " bytes.");
      
      buf.setOffset(0);
      buf.setLength((int)raFile.length());
      buf.setFormat(format);
      buf.setFlags(buf.getFlags() | buf.FLAG_KEY_FRAME);
      buf.setTimeStamp(frame++ * Time.ONE_SECOND/fRate); /*AVI*/

      
      // Close the random access file.
      raFile.close();
    }