コード例 #1
0
  /**
   * If the frame body's values have been modified, then resize the raw binary buffer and store the
   * new values there. When finished, the dirty flag is reset to indicate that the buffer is up to
   * date, and the frame is now ready to be saved to the .mp3 file.
   */
  @Override
  public void setBuffer() {
    if (isDirty()) {
      int numSynchronizedLyricBytes = 0;
      for (SynchronizedLyric synchronizedLyric : synchronizedLyrics)
        numSynchronizedLyricBytes +=
            stringToBytes(encoding, synchronizedLyric.getText()).length + 4;

      byte[] languageBytes = language.getCodeBytes();
      byte[] descriptionBytes = stringToBytes(encoding, description);
      byte[] synchronizedLyricBytes = new byte[numSynchronizedLyricBytes];
      byte[] textBytes = null;
      byte[] timeStampBytes = null;
      int index = 0;

      buffer =
          new byte
              [1
                  + languageBytes.length
                  + 1
                  + 1
                  + descriptionBytes.length
                  + synchronizedLyricBytes.length];

      buffer[index] = (byte) encoding.ordinal();
      index = 1;
      System.arraycopy(languageBytes, 0, buffer, index, languageBytes.length);
      index += languageBytes.length;
      buffer[index] = (byte) timeStampFormat.getValue();
      index++;
      buffer[index] = (byte) contentType.ordinal();
      index++;
      System.arraycopy(descriptionBytes, 0, buffer, index, descriptionBytes.length);
      index += descriptionBytes.length;
      for (SynchronizedLyric synchronizedLyric : synchronizedLyrics) {
        numSynchronizedLyricBytes +=
            stringToBytes(encoding, synchronizedLyric.getText()).length + 4;
        textBytes = stringToBytes(encoding, synchronizedLyric.getText());
        System.arraycopy(textBytes, 0, buffer, index, textBytes.length);
        index += textBytes.length;
        timeStampBytes = intToBytes(synchronizedLyric.getTimeStamp());
        System.arraycopy(timeStampBytes, 0, buffer, index, timeStampBytes.length);
        index += timeStampBytes.length;
      }
      dirty = false;
    }
  }
コード例 #2
0
  /**
   * If the frame body's values have been modified, then resize the raw binary buffer and store the
   * new values there. When finished, the dirty flag is reset to indicate that the buffer is up to
   * date, and the frame is now ready to be saved to the .mp3 file.
   */
  @Override
  public void setBuffer() {
    if (isDirty()) {
      byte[] languageBytes = language.getCodeBytes();
      byte[] textBytes = stringToBytes(encoding, text);
      int index = 0;

      buffer = new byte[1 + languageBytes.length + textBytes.length];

      buffer[index] = (byte) encoding.ordinal();
      index = 1;
      System.arraycopy(languageBytes, 0, buffer, index, languageBytes.length);
      index += languageBytes.length;
      System.arraycopy(textBytes, 0, buffer, index, textBytes.length);

      dirty = false;
    }
  }