code: public int getFrameForTimestampMs(int frameTimestampsMs[], int timestampMs) {
      int index = Arrays.binarySearch(frameTimestampsMs, timestampMs);
      if (index < 0) {
        return -index - 1 - 1;
      } else {
        return index;
      }
    }
docs: Gets the frame index for specified timestamp.
  
  @param frameTimestampsMs an array of timestamps generated by {@link #getFrameForTimestampMs)}
  @param timestampMs the timestamp
  @return the frame index for the timestamp or the last frame number if the timestamp is outside
  the duration of the entire animation