com.google.android.exoplayer2.metadata.id3.InternalFrame Java Examples

The following examples show how to use com.google.android.exoplayer2.metadata.id3.InternalFrame. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GaplessInfoHolder.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Populates the holder with data parsed from ID3 {@link Metadata}.
 *
 * @param metadata The metadata from which to parse the gapless information.
 * @return Whether the holder was populated.
 */
public boolean setFromMetadata(Metadata metadata) {
  for (int i = 0; i < metadata.length(); i++) {
    Metadata.Entry entry = metadata.get(i);
    if (entry instanceof CommentFrame) {
      CommentFrame commentFrame = (CommentFrame) entry;
      if (GAPLESS_DESCRIPTION.equals(commentFrame.description)
          && setFromComment(commentFrame.text)) {
        return true;
      }
    } else if (entry instanceof InternalFrame) {
      InternalFrame internalFrame = (InternalFrame) entry;
      if (GAPLESS_DOMAIN.equals(internalFrame.domain)
          && GAPLESS_DESCRIPTION.equals(internalFrame.description)
          && setFromComment(internalFrame.text)) {
        return true;
      }
    }
  }
  return false;
}
 
Example #2
Source File: GaplessInfoHolder.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Populates the holder with data parsed from ID3 {@link Metadata}.
 *
 * @param metadata The metadata from which to parse the gapless information.
 * @return Whether the holder was populated.
 */
public boolean setFromMetadata(Metadata metadata) {
  for (int i = 0; i < metadata.length(); i++) {
    Metadata.Entry entry = metadata.get(i);
    if (entry instanceof CommentFrame) {
      CommentFrame commentFrame = (CommentFrame) entry;
      if (GAPLESS_DESCRIPTION.equals(commentFrame.description)
          && setFromComment(commentFrame.text)) {
        return true;
      }
    } else if (entry instanceof InternalFrame) {
      InternalFrame internalFrame = (InternalFrame) entry;
      if (GAPLESS_DOMAIN.equals(internalFrame.domain)
          && GAPLESS_DESCRIPTION.equals(internalFrame.description)
          && setFromComment(internalFrame.text)) {
        return true;
      }
    }
  }
  return false;
}
 
Example #3
Source File: GaplessInfoHolder.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Populates the holder with data parsed from ID3 {@link Metadata}.
 *
 * @param metadata The metadata from which to parse the gapless information.
 * @return Whether the holder was populated.
 */
public boolean setFromMetadata(Metadata metadata) {
  for (int i = 0; i < metadata.length(); i++) {
    Metadata.Entry entry = metadata.get(i);
    if (entry instanceof CommentFrame) {
      CommentFrame commentFrame = (CommentFrame) entry;
      if (GAPLESS_DESCRIPTION.equals(commentFrame.description)
          && setFromComment(commentFrame.text)) {
        return true;
      }
    } else if (entry instanceof InternalFrame) {
      InternalFrame internalFrame = (InternalFrame) entry;
      if (GAPLESS_DOMAIN.equals(internalFrame.domain)
          && GAPLESS_DESCRIPTION.equals(internalFrame.description)
          && setFromComment(internalFrame.text)) {
        return true;
      }
    }
  }
  return false;
}
 
Example #4
Source File: GaplessInfoHolder.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Populates the holder with data parsed from ID3 {@link Metadata}.
 *
 * @param metadata The metadata from which to parse the gapless information.
 * @return Whether the holder was populated.
 */
public boolean setFromMetadata(Metadata metadata) {
  for (int i = 0; i < metadata.length(); i++) {
    Metadata.Entry entry = metadata.get(i);
    if (entry instanceof CommentFrame) {
      CommentFrame commentFrame = (CommentFrame) entry;
      if (GAPLESS_DESCRIPTION.equals(commentFrame.description)
          && setFromComment(commentFrame.text)) {
        return true;
      }
    } else if (entry instanceof InternalFrame) {
      InternalFrame internalFrame = (InternalFrame) entry;
      if (GAPLESS_DOMAIN.equals(internalFrame.domain)
          && GAPLESS_DESCRIPTION.equals(internalFrame.description)
          && setFromComment(internalFrame.text)) {
        return true;
      }
    }
  }
  return false;
}
 
Example #5
Source File: GaplessInfoHolder.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Populates the holder with data parsed from ID3 {@link Metadata}.
 *
 * @param metadata The metadata from which to parse the gapless information.
 * @return Whether the holder was populated.
 */
public boolean setFromMetadata(Metadata metadata) {
  for (int i = 0; i < metadata.length(); i++) {
    Metadata.Entry entry = metadata.get(i);
    if (entry instanceof CommentFrame) {
      CommentFrame commentFrame = (CommentFrame) entry;
      if (GAPLESS_DESCRIPTION.equals(commentFrame.description)
          && setFromComment(commentFrame.text)) {
        return true;
      }
    } else if (entry instanceof InternalFrame) {
      InternalFrame internalFrame = (InternalFrame) entry;
      if (GAPLESS_DOMAIN.equals(internalFrame.domain)
          && GAPLESS_DESCRIPTION.equals(internalFrame.description)
          && setFromComment(internalFrame.text)) {
        return true;
      }
    }
  }
  return false;
}
 
Example #6
Source File: MetadataUtil.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Nullable
private static Id3Frame parseInternalAttribute(ParsableByteArray data, int endPosition) {
  String domain = null;
  String name = null;
  int dataAtomPosition = -1;
  int dataAtomSize = -1;
  while (data.getPosition() < endPosition) {
    int atomPosition = data.getPosition();
    int atomSize = data.readInt();
    int atomType = data.readInt();
    data.skipBytes(4); // version (1), flags (3)
    if (atomType == Atom.TYPE_mean) {
      domain = data.readNullTerminatedString(atomSize - 12);
    } else if (atomType == Atom.TYPE_name) {
      name = data.readNullTerminatedString(atomSize - 12);
    } else {
      if (atomType == Atom.TYPE_data) {
        dataAtomPosition = atomPosition;
        dataAtomSize = atomSize;
      }
      data.skipBytes(atomSize - 12);
    }
  }
  if (domain == null || name == null || dataAtomPosition == -1) {
    return null;
  }
  data.setPosition(dataAtomPosition);
  data.skipBytes(16); // size (4), type (4), version (1), flags (3), empty (4)
  String value = data.readNullTerminatedString(dataAtomSize - 16);
  return new InternalFrame(domain, name, value);
}
 
Example #7
Source File: MetadataUtil.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static @Nullable Id3Frame parseInternalAttribute(
    ParsableByteArray data, int endPosition) {
  String domain = null;
  String name = null;
  int dataAtomPosition = -1;
  int dataAtomSize = -1;
  while (data.getPosition() < endPosition) {
    int atomPosition = data.getPosition();
    int atomSize = data.readInt();
    int atomType = data.readInt();
    data.skipBytes(4); // version (1), flags (3)
    if (atomType == Atom.TYPE_mean) {
      domain = data.readNullTerminatedString(atomSize - 12);
    } else if (atomType == Atom.TYPE_name) {
      name = data.readNullTerminatedString(atomSize - 12);
    } else {
      if (atomType == Atom.TYPE_data) {
        dataAtomPosition = atomPosition;
        dataAtomSize = atomSize;
      }
      data.skipBytes(atomSize - 12);
    }
  }
  if (domain == null || name == null || dataAtomPosition == -1) {
    return null;
  }
  data.setPosition(dataAtomPosition);
  data.skipBytes(16); // size (4), type (4), version (1), flags (3), empty (4)
  String value = data.readNullTerminatedString(dataAtomSize - 16);
  return new InternalFrame(domain, name, value);
}
 
Example #8
Source File: MetadataUtil.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private static @Nullable Id3Frame parseInternalAttribute(
    ParsableByteArray data, int endPosition) {
  String domain = null;
  String name = null;
  int dataAtomPosition = -1;
  int dataAtomSize = -1;
  while (data.getPosition() < endPosition) {
    int atomPosition = data.getPosition();
    int atomSize = data.readInt();
    int atomType = data.readInt();
    data.skipBytes(4); // version (1), flags (3)
    if (atomType == Atom.TYPE_mean) {
      domain = data.readNullTerminatedString(atomSize - 12);
    } else if (atomType == Atom.TYPE_name) {
      name = data.readNullTerminatedString(atomSize - 12);
    } else {
      if (atomType == Atom.TYPE_data) {
        dataAtomPosition = atomPosition;
        dataAtomSize = atomSize;
      }
      data.skipBytes(atomSize - 12);
    }
  }
  if (domain == null || name == null || dataAtomPosition == -1) {
    return null;
  }
  data.setPosition(dataAtomPosition);
  data.skipBytes(16); // size (4), type (4), version (1), flags (3), empty (4)
  String value = data.readNullTerminatedString(dataAtomSize - 16);
  return new InternalFrame(domain, name, value);
}
 
Example #9
Source File: MetadataUtil.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Nullable
private static Id3Frame parseInternalAttribute(ParsableByteArray data, int endPosition) {
  String domain = null;
  String name = null;
  int dataAtomPosition = -1;
  int dataAtomSize = -1;
  while (data.getPosition() < endPosition) {
    int atomPosition = data.getPosition();
    int atomSize = data.readInt();
    int atomType = data.readInt();
    data.skipBytes(4); // version (1), flags (3)
    if (atomType == Atom.TYPE_mean) {
      domain = data.readNullTerminatedString(atomSize - 12);
    } else if (atomType == Atom.TYPE_name) {
      name = data.readNullTerminatedString(atomSize - 12);
    } else {
      if (atomType == Atom.TYPE_data) {
        dataAtomPosition = atomPosition;
        dataAtomSize = atomSize;
      }
      data.skipBytes(atomSize - 12);
    }
  }
  if (domain == null || name == null || dataAtomPosition == -1) {
    return null;
  }
  data.setPosition(dataAtomPosition);
  data.skipBytes(16); // size (4), type (4), version (1), flags (3), empty (4)
  String value = data.readNullTerminatedString(dataAtomSize - 16);
  return new InternalFrame(domain, name, value);
}
 
Example #10
Source File: MetadataUtil.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Nullable
private static Id3Frame parseInternalAttribute(ParsableByteArray data, int endPosition) {
  String domain = null;
  String name = null;
  int dataAtomPosition = -1;
  int dataAtomSize = -1;
  while (data.getPosition() < endPosition) {
    int atomPosition = data.getPosition();
    int atomSize = data.readInt();
    int atomType = data.readInt();
    data.skipBytes(4); // version (1), flags (3)
    if (atomType == Atom.TYPE_mean) {
      domain = data.readNullTerminatedString(atomSize - 12);
    } else if (atomType == Atom.TYPE_name) {
      name = data.readNullTerminatedString(atomSize - 12);
    } else {
      if (atomType == Atom.TYPE_data) {
        dataAtomPosition = atomPosition;
        dataAtomSize = atomSize;
      }
      data.skipBytes(atomSize - 12);
    }
  }
  if (domain == null || name == null || dataAtomPosition == -1) {
    return null;
  }
  data.setPosition(dataAtomPosition);
  data.skipBytes(16); // size (4), type (4), version (1), flags (3), empty (4)
  String value = data.readNullTerminatedString(dataAtomSize - 16);
  return new InternalFrame(domain, name, value);
}