Java Code Examples for com.google.android.exoplayer2.metadata.Metadata#get()

The following examples show how to use com.google.android.exoplayer2.metadata.Metadata#get() . 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: EventLogger.java    From TigerVideo with Apache License 2.0 5 votes vote down vote up
private void printMetadata(Metadata metadata, String prefix) {
    for (int i = 0; i < metadata.length(); i++) {
        Metadata.Entry entry = metadata.get(i);
        if (entry instanceof TextInformationFrame) {
            TextInformationFrame textInformationFrame = (TextInformationFrame) entry;
            Log.d(TAG, prefix + String.format("%s: value=%s", textInformationFrame.id,
                    textInformationFrame.value));
        } else if (entry instanceof UrlLinkFrame) {
            UrlLinkFrame urlLinkFrame = (UrlLinkFrame) entry;
            Log.d(TAG, prefix + String.format("%s: url=%s", urlLinkFrame.id, urlLinkFrame.url));
        } else if (entry instanceof PrivFrame) {
            PrivFrame privFrame = (PrivFrame) entry;
            Log.d(TAG, prefix + String.format("%s: owner=%s", privFrame.id, privFrame.owner));
        } else if (entry instanceof GeobFrame) {
            GeobFrame geobFrame = (GeobFrame) entry;
            Log.d(TAG, prefix + String.format("%s: mimeType=%s, filename=%s, description=%s",
                    geobFrame.id, geobFrame.mimeType, geobFrame.filename, geobFrame.description));
        } else if (entry instanceof ApicFrame) {
            ApicFrame apicFrame = (ApicFrame) entry;
            Log.d(TAG, prefix + String.format("%s: mimeType=%s, description=%s",
                    apicFrame.id, apicFrame.mimeType, apicFrame.description));
        } else if (entry instanceof CommentFrame) {
            CommentFrame commentFrame = (CommentFrame) entry;
            Log.d(TAG, prefix + String.format("%s: language=%s, description=%s", commentFrame.id,
                    commentFrame.language, commentFrame.description));
        } else if (entry instanceof Id3Frame) {
            Id3Frame id3Frame = (Id3Frame) entry;
            Log.d(TAG, prefix + String.format("%s", id3Frame.id));
        } else if (entry instanceof EventMessage) {
            EventMessage eventMessage = (EventMessage) entry;
            Log.d(TAG, prefix + String.format("EMSG: scheme=%s, id=%d, value=%s",
                    eventMessage.schemeIdUri, eventMessage.id, eventMessage.value));
        }
    }
}
 
Example 5
Source File: SimpleExoPlayerView.java    From K-Sonic with MIT License 5 votes vote down vote up
private boolean setArtworkFromMetadata(Metadata metadata) {
  for (int i = 0; i < metadata.length(); i++) {
    Metadata.Entry metadataEntry = metadata.get(i);
    if (metadataEntry instanceof ApicFrame) {
      byte[] bitmapData = ((ApicFrame) metadataEntry).pictureData;
      Bitmap bitmap = BitmapFactory.decodeByteArray(bitmapData, 0, bitmapData.length);
      return setArtworkFromBitmap(bitmap);
    }
  }
  return false;
}
 
Example 6
Source File: EventLogger.java    From K-Sonic with MIT License 5 votes vote down vote up
private void printMetadata(Metadata metadata, String prefix) {
  for (int i = 0; i < metadata.length(); i++) {
    Metadata.Entry entry = metadata.get(i);
    if (entry instanceof TextInformationFrame) {
      TextInformationFrame textInformationFrame = (TextInformationFrame) entry;
      Log.d(TAG, prefix + String.format("%s: value=%s", textInformationFrame.id,
              textInformationFrame.value));
    } else if (entry instanceof UrlLinkFrame) {
      UrlLinkFrame urlLinkFrame = (UrlLinkFrame) entry;
      Log.d(TAG, prefix + String.format("%s: url=%s", urlLinkFrame.id, urlLinkFrame.url));
    } else if (entry instanceof PrivFrame) {
      PrivFrame privFrame = (PrivFrame) entry;
      Log.d(TAG, prefix + String.format("%s: owner=%s", privFrame.id, privFrame.owner));
    } else if (entry instanceof GeobFrame) {
      GeobFrame geobFrame = (GeobFrame) entry;
      Log.d(TAG, prefix + String.format("%s: mimeType=%s, filename=%s, description=%s",
              geobFrame.id, geobFrame.mimeType, geobFrame.filename, geobFrame.description));
    } else if (entry instanceof ApicFrame) {
      ApicFrame apicFrame = (ApicFrame) entry;
      Log.d(TAG, prefix + String.format("%s: mimeType=%s, description=%s",
              apicFrame.id, apicFrame.mimeType, apicFrame.description));
    } else if (entry instanceof CommentFrame) {
      CommentFrame commentFrame = (CommentFrame) entry;
      Log.d(TAG, prefix + String.format("%s: language=%s, description=%s", commentFrame.id,
              commentFrame.language, commentFrame.description));
    } else if (entry instanceof Id3Frame) {
      Id3Frame id3Frame = (Id3Frame) entry;
      Log.d(TAG, prefix + String.format("%s", id3Frame.id));
    } else if (entry instanceof EventMessage) {
      EventMessage eventMessage = (EventMessage) entry;
      Log.d(TAG, prefix + String.format("EMSG: scheme=%s, id=%d, value=%s",
              eventMessage.schemeIdUri, eventMessage.id, eventMessage.value));
    }
  }
}
 
Example 7
Source File: ExoVideoView.java    From ExoVideoView with Apache License 2.0 5 votes vote down vote up
private boolean setArtworkFromMetadata(Metadata metadata) {
    for (int i = 0; i < metadata.length(); i++) {
        Metadata.Entry metadataEntry = metadata.get(i);
        if (metadataEntry instanceof ApicFrame) {
            byte[] bitmapData = ((ApicFrame) metadataEntry).pictureData;
            Bitmap bitmap = BitmapFactory.decodeByteArray(bitmapData, 0, bitmapData.length);
            return setArtworkFromBitmap(bitmap);
        }
    }
    return false;
}
 
Example 8
Source File: EventLogger.java    From mimi-reader with Apache License 2.0 5 votes vote down vote up
private void printMetadata(Metadata metadata, String prefix) {
    for (int i = 0; i < metadata.length(); i++) {
        Metadata.Entry entry = metadata.get(i);
        if (entry instanceof TextInformationFrame) {
            TextInformationFrame textInformationFrame = (TextInformationFrame) entry;
            Log.d(TAG, prefix + String.format("%s: value=%s", textInformationFrame.id,
                    textInformationFrame.value));
        } else if (entry instanceof UrlLinkFrame) {
            UrlLinkFrame urlLinkFrame = (UrlLinkFrame) entry;
            Log.d(TAG, prefix + String.format("%s: url=%s", urlLinkFrame.id, urlLinkFrame.url));
        } else if (entry instanceof PrivFrame) {
            PrivFrame privFrame = (PrivFrame) entry;
            Log.d(TAG, prefix + String.format("%s: owner=%s", privFrame.id, privFrame.owner));
        } else if (entry instanceof GeobFrame) {
            GeobFrame geobFrame = (GeobFrame) entry;
            Log.d(TAG, prefix + String.format("%s: mimeType=%s, filename=%s, description=%s",
                    geobFrame.id, geobFrame.mimeType, geobFrame.filename, geobFrame.description));
        } else if (entry instanceof ApicFrame) {
            ApicFrame apicFrame = (ApicFrame) entry;
            Log.d(TAG, prefix + String.format("%s: mimeType=%s, description=%s",
                    apicFrame.id, apicFrame.mimeType, apicFrame.description));
        } else if (entry instanceof CommentFrame) {
            CommentFrame commentFrame = (CommentFrame) entry;
            Log.d(TAG, prefix + String.format("%s: language=%s, description=%s", commentFrame.id,
                    commentFrame.language, commentFrame.description));
        } else if (entry instanceof Id3Frame) {
            Id3Frame id3Frame = (Id3Frame) entry;
            Log.d(TAG, prefix + String.format("%s", id3Frame.id));
        } else if (entry instanceof EventMessage) {
            EventMessage eventMessage = (EventMessage) entry;
            Log.d(TAG, prefix + String.format("EMSG: scheme=%s, id=%d, value=%s",
                    eventMessage.schemeIdUri, eventMessage.id, eventMessage.value));
        }
    }
}
 
Example 9
Source File: EventLogger.java    From LiveVideoBroadcaster with Apache License 2.0 5 votes vote down vote up
private void printMetadata(Metadata metadata, String prefix) {
  for (int i = 0; i < metadata.length(); i++) {
    Metadata.Entry entry = metadata.get(i);
    if (entry instanceof TextInformationFrame) {
      TextInformationFrame textInformationFrame = (TextInformationFrame) entry;
      Log.d(TAG, prefix + String.format("%s: value=%s", textInformationFrame.id,
          textInformationFrame.value));
    } else if (entry instanceof UrlLinkFrame) {
      UrlLinkFrame urlLinkFrame = (UrlLinkFrame) entry;
      Log.d(TAG, prefix + String.format("%s: url=%s", urlLinkFrame.id, urlLinkFrame.url));
    } else if (entry instanceof PrivFrame) {
      PrivFrame privFrame = (PrivFrame) entry;
      Log.d(TAG, prefix + String.format("%s: owner=%s", privFrame.id, privFrame.owner));
    } else if (entry instanceof GeobFrame) {
      GeobFrame geobFrame = (GeobFrame) entry;
      Log.d(TAG, prefix + String.format("%s: mimeType=%s, filename=%s, description=%s",
          geobFrame.id, geobFrame.mimeType, geobFrame.filename, geobFrame.description));
    } else if (entry instanceof ApicFrame) {
      ApicFrame apicFrame = (ApicFrame) entry;
      Log.d(TAG, prefix + String.format("%s: mimeType=%s, description=%s",
          apicFrame.id, apicFrame.mimeType, apicFrame.description));
    } else if (entry instanceof CommentFrame) {
      CommentFrame commentFrame = (CommentFrame) entry;
      Log.d(TAG, prefix + String.format("%s: language=%s, description=%s", commentFrame.id,
          commentFrame.language, commentFrame.description));
    } else if (entry instanceof Id3Frame) {
      Id3Frame id3Frame = (Id3Frame) entry;
      Log.d(TAG, prefix + String.format("%s", id3Frame.id));
    } else if (entry instanceof EventMessage) {
      EventMessage eventMessage = (EventMessage) entry;
      Log.d(TAG, prefix + String.format("EMSG: scheme=%s, id=%d, value=%s",
          eventMessage.schemeIdUri, eventMessage.id, eventMessage.value));
    }
  }
}
 
Example 10
Source File: EventLogger.java    From ExoPlayer-Offline with Apache License 2.0 5 votes vote down vote up
private void printMetadata(Metadata metadata, String prefix) {
  for (int i = 0; i < metadata.length(); i++) {
    Metadata.Entry entry = metadata.get(i);
    if (entry instanceof TextInformationFrame) {
      TextInformationFrame textInformationFrame = (TextInformationFrame) entry;
      Log.d(TAG, prefix + String.format("%s: value=%s", textInformationFrame.id,
          textInformationFrame.value));
    } else if (entry instanceof UrlLinkFrame) {
      UrlLinkFrame urlLinkFrame = (UrlLinkFrame) entry;
      Log.d(TAG, prefix + String.format("%s: url=%s", urlLinkFrame.id, urlLinkFrame.url));
    } else if (entry instanceof PrivFrame) {
      PrivFrame privFrame = (PrivFrame) entry;
      Log.d(TAG, prefix + String.format("%s: owner=%s", privFrame.id, privFrame.owner));
    } else if (entry instanceof GeobFrame) {
      GeobFrame geobFrame = (GeobFrame) entry;
      Log.d(TAG, prefix + String.format("%s: mimeType=%s, filename=%s, description=%s",
          geobFrame.id, geobFrame.mimeType, geobFrame.filename, geobFrame.description));
    } else if (entry instanceof ApicFrame) {
      ApicFrame apicFrame = (ApicFrame) entry;
      Log.d(TAG, prefix + String.format("%s: mimeType=%s, description=%s",
          apicFrame.id, apicFrame.mimeType, apicFrame.description));
    } else if (entry instanceof CommentFrame) {
      CommentFrame commentFrame = (CommentFrame) entry;
      Log.d(TAG, prefix + String.format("%s: language=%s, description=%s", commentFrame.id,
          commentFrame.language, commentFrame.description));
    } else if (entry instanceof Id3Frame) {
      Id3Frame id3Frame = (Id3Frame) entry;
      Log.d(TAG, prefix + String.format("%s", id3Frame.id));
    } else if (entry instanceof EventMessage) {
      EventMessage eventMessage = (EventMessage) entry;
      Log.d(TAG, prefix + String.format("EMSG: scheme=%s, id=%d, value=%s",
          eventMessage.schemeIdUri, eventMessage.id, eventMessage.value));
    }
  }
}
 
Example 11
Source File: EventLogger.java    From TubiPlayer with MIT License 5 votes vote down vote up
private void printMetadata(Metadata metadata, String prefix) {
    for (int i = 0; i < metadata.length(); i++) {
        Metadata.Entry entry = metadata.get(i);
        if (entry instanceof TextInformationFrame) {
            TextInformationFrame textInformationFrame = (TextInformationFrame) entry;
            Log.d(TAG, prefix + String.format("%s: value=%s", textInformationFrame.id,
                    textInformationFrame.value));
        } else if (entry instanceof UrlLinkFrame) {
            UrlLinkFrame urlLinkFrame = (UrlLinkFrame) entry;
            Log.d(TAG, prefix + String.format("%s: url=%s", urlLinkFrame.id, urlLinkFrame.url));
        } else if (entry instanceof PrivFrame) {
            PrivFrame privFrame = (PrivFrame) entry;
            Log.d(TAG, prefix + String.format("%s: owner=%s", privFrame.id, privFrame.owner));
        } else if (entry instanceof GeobFrame) {
            GeobFrame geobFrame = (GeobFrame) entry;
            Log.d(TAG, prefix + String.format("%s: mimeType=%s, filename=%s, description=%s",
                    geobFrame.id, geobFrame.mimeType, geobFrame.filename, geobFrame.description));
        } else if (entry instanceof ApicFrame) {
            ApicFrame apicFrame = (ApicFrame) entry;
            Log.d(TAG, prefix + String.format("%s: mimeType=%s, description=%s",
                    apicFrame.id, apicFrame.mimeType, apicFrame.description));
        } else if (entry instanceof CommentFrame) {
            CommentFrame commentFrame = (CommentFrame) entry;
            Log.d(TAG, prefix + String.format("%s: language=%s, description=%s", commentFrame.id,
                    commentFrame.language, commentFrame.description));
        } else if (entry instanceof Id3Frame) {
            Id3Frame id3Frame = (Id3Frame) entry;
            Log.d(TAG, prefix + String.format("%s", id3Frame.id));
        } else if (entry instanceof EventMessage) {
            EventMessage eventMessage = (EventMessage) entry;
            Log.d(TAG, prefix + String.format("EMSG: scheme=%s, id=%d, value=%s",
                    eventMessage.schemeIdUri, eventMessage.id, eventMessage.value));
        }
    }
}
 
Example 12
Source File: GaplessInfoHolder.java    From K-Sonic with MIT License 5 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 (setFromComment(commentFrame.description, commentFrame.text)) {
        return true;
      }
    }
  }
  return false;
}
 
Example 13
Source File: EventLogger.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
private void printMetadata(Metadata metadata, String prefix) {
  for (int i = 0; i < metadata.length(); i++) {
    Metadata.Entry entry = metadata.get(i);
    if (entry instanceof TextInformationFrame) {
      TextInformationFrame textInformationFrame = (TextInformationFrame) entry;
      Log.d(TAG, prefix + String.format("%s: value=%s", textInformationFrame.id,
          textInformationFrame.value));
    } else if (entry instanceof UrlLinkFrame) {
      UrlLinkFrame urlLinkFrame = (UrlLinkFrame) entry;
      Log.d(TAG, prefix + String.format("%s: url=%s", urlLinkFrame.id, urlLinkFrame.url));
    } else if (entry instanceof PrivFrame) {
      PrivFrame privFrame = (PrivFrame) entry;
      Log.d(TAG, prefix + String.format("%s: owner=%s", privFrame.id, privFrame.owner));
    } else if (entry instanceof GeobFrame) {
      GeobFrame geobFrame = (GeobFrame) entry;
      Log.d(TAG, prefix + String.format("%s: mimeType=%s, filename=%s, description=%s",
          geobFrame.id, geobFrame.mimeType, geobFrame.filename, geobFrame.description));
    } else if (entry instanceof ApicFrame) {
      ApicFrame apicFrame = (ApicFrame) entry;
      Log.d(TAG, prefix + String.format("%s: mimeType=%s, description=%s",
          apicFrame.id, apicFrame.mimeType, apicFrame.description));
    } else if (entry instanceof CommentFrame) {
      CommentFrame commentFrame = (CommentFrame) entry;
      Log.d(TAG, prefix + String.format("%s: language=%s, description=%s", commentFrame.id,
          commentFrame.language, commentFrame.description));
    } else if (entry instanceof Id3Frame) {
      Id3Frame id3Frame = (Id3Frame) entry;
      Log.d(TAG, prefix + String.format("%s", id3Frame.id));
    } else if (entry instanceof EventMessage) {
      EventMessage eventMessage = (EventMessage) entry;
      Log.d(TAG, prefix + String.format("EMSG: scheme=%s, id=%d, value=%s",
          eventMessage.schemeIdUri, eventMessage.id, eventMessage.value));
    }
  }
}
 
Example 14
Source File: ExoPlayerFragment.java    From carstream-android-auto with Apache License 2.0 5 votes vote down vote up
@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
    playerQueue.resetPosition(player.getCurrentWindowIndex());
    String album = null;
    String title = null;
    for (int i = 0; i < trackGroups.length; i++) {
        TrackGroup trackGroup = trackGroups.get(i);
        for (int j = 0; j < trackGroup.length; j++) {
            Metadata trackMetadata = trackGroup.getFormat(j).metadata;
            if (trackMetadata != null) {
                for (int k = 0; k < trackMetadata.length(); k++) {
                    Metadata.Entry entry = trackMetadata.get(k);
                    if (entry instanceof TextInformationFrame) {
                        TextInformationFrame textInformationFrame = (TextInformationFrame) entry;
                        String id = textInformationFrame.id;
                        if (id != null && id.equals("TALB")) {
                            album = textInformationFrame.value;
                        } else if (id != null && id.equals("TIT2")) {
                            title = textInformationFrame.value;
                        }

                    }
                }
            }
        }
    }
    if (title != null || album != null) {
        if (title != null) {
            titleView.setText(title);
        }
        if (album != null) {
            albumView.setText(album);
        }
        BroadcastFromUI.broadcastTitle(getContext(), title);
    } else {
        File file = new File(playerQueue.current());
        titleView.setText(file.getName());
        albumView.setText(file.getParent());
    }
}
 
Example 15
Source File: PlayerEmsgHandler.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void parseAndDiscardSamples() {
  while (sampleQueue.hasNextSample()) {
    MetadataInputBuffer inputBuffer = dequeueSample();
    if (inputBuffer == null) {
      continue;
    }
    long eventTimeUs = inputBuffer.timeUs;
    Metadata metadata = decoder.decode(inputBuffer);
    EventMessage eventMessage = (EventMessage) metadata.get(0);
    if (isPlayerEmsgEvent(eventMessage.schemeIdUri, eventMessage.value)) {
      parsePlayerEmsgEvent(eventTimeUs, eventMessage);
    }
  }
  sampleQueue.discardToRead();
}
 
Example 16
Source File: CustomizePlayerView.java    From bcm-android with GNU General Public License v3.0 5 votes vote down vote up
private boolean setArtworkFromMetadata(Metadata metadata) {
    for (int i = 0; i < metadata.length(); i++) {
        Metadata.Entry metadataEntry = metadata.get(i);
        if (metadataEntry instanceof ApicFrame) {
            byte[] bitmapData = ((ApicFrame) metadataEntry).pictureData;
            Bitmap bitmap = BitmapFactory.decodeByteArray(bitmapData, 0, bitmapData.length);
            return setArtworkFromBitmap(bitmap);
        }
    }
    return false;
}
 
Example 17
Source File: PlayerEmsgHandler.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private void parseAndDiscardSamples() {
  while (sampleQueue.isReady(/* loadingFinished= */ false)) {
    MetadataInputBuffer inputBuffer = dequeueSample();
    if (inputBuffer == null) {
      continue;
    }
    long eventTimeUs = inputBuffer.timeUs;
    Metadata metadata = decoder.decode(inputBuffer);
    EventMessage eventMessage = (EventMessage) metadata.get(0);
    if (isPlayerEmsgEvent(eventMessage.schemeIdUri, eventMessage.value)) {
      parsePlayerEmsgEvent(eventTimeUs, eventMessage);
    }
  }
  sampleQueue.discardToRead();
}
 
Example 18
Source File: DefaultHlsExtractorFactory.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/** Returns true if this {@code format} represents a 'variant' track (i.e. the main one). */
private static boolean isFmp4Variant(Format format) {
  Metadata metadata = format.metadata;
  if (metadata == null) {
    return false;
  }
  for (int i = 0; i < metadata.length(); i++) {
    Metadata.Entry entry = metadata.get(i);
    if (entry instanceof HlsTrackMetadataEntry) {
      return !((HlsTrackMetadataEntry) entry).variantInfos.isEmpty();
    }
  }
  return false;
}
 
Example 19
Source File: HlsSampleStreamWrapper.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * Strips the private timestamp frame from metadata, if present. See:
 * https://github.com/google/ExoPlayer/issues/5063
 */
@Nullable
private Metadata getAdjustedMetadata(@Nullable Metadata metadata) {
  if (metadata == null) {
    return null;
  }
  int length = metadata.length();
  int transportStreamTimestampMetadataIndex = C.INDEX_UNSET;
  for (int i = 0; i < length; i++) {
    Metadata.Entry metadataEntry = metadata.get(i);
    if (metadataEntry instanceof PrivFrame) {
      PrivFrame privFrame = (PrivFrame) metadataEntry;
      if (HlsMediaChunk.PRIV_TIMESTAMP_FRAME_OWNER.equals(privFrame.owner)) {
        transportStreamTimestampMetadataIndex = i;
        break;
      }
    }
  }
  if (transportStreamTimestampMetadataIndex == C.INDEX_UNSET) {
    return metadata;
  }
  if (length == 1) {
    return null;
  }
  Metadata.Entry[] newMetadataEntries = new Metadata.Entry[length - 1];
  for (int i = 0; i < length; i++) {
    if (i != transportStreamTimestampMetadataIndex) {
      int newIndex = i < transportStreamTimestampMetadataIndex ? i : i - 1;
      newMetadataEntries[newIndex] = metadata.get(i);
    }
  }
  return new Metadata(newMetadataEntries);
}
 
Example 20
Source File: Mp3Extractor.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Nullable
private static MlltSeeker maybeHandleSeekMetadata(Metadata metadata, long firstFramePosition) {
  if (metadata != null) {
    int length = metadata.length();
    for (int i = 0; i < length; i++) {
      Metadata.Entry entry = metadata.get(i);
      if (entry instanceof MlltFrame) {
        return MlltSeeker.create(firstFramePosition, (MlltFrame) entry);
      }
    }
  }
  return null;
}