Java Code Examples for com.google.android.exoplayer2.metadata.Metadata#length()
The following examples show how to use
com.google.android.exoplayer2.metadata.Metadata#length() .
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 |
/** * 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 |
/** * 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 |
/** * 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 |
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: MetadataUtil.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * Returns a {@link Format} that is the same as the input format but includes information from the * specified sources of metadata. */ public static Format getFormatWithMetadata( int trackType, Format format, @Nullable Metadata udtaMetadata, @Nullable Metadata mdtaMetadata, GaplessInfoHolder gaplessInfoHolder) { if (trackType == C.TRACK_TYPE_AUDIO) { if (gaplessInfoHolder.hasGaplessInfo()) { format = format.copyWithGaplessInfo( gaplessInfoHolder.encoderDelay, gaplessInfoHolder.encoderPadding); } // We assume all udta metadata is associated with the audio track. if (udtaMetadata != null) { format = format.copyWithMetadata(udtaMetadata); } } else if (trackType == C.TRACK_TYPE_VIDEO && mdtaMetadata != null) { // Populate only metadata keys that are known to be specific to video. for (int i = 0; i < mdtaMetadata.length(); i++) { Metadata.Entry entry = mdtaMetadata.get(i); if (entry instanceof MdtaMetadataEntry) { MdtaMetadataEntry mdtaMetadataEntry = (MdtaMetadataEntry) entry; if (MDTA_KEY_ANDROID_CAPTURE_FPS.equals(mdtaMetadataEntry.key) && mdtaMetadataEntry.typeIndicator == MDTA_TYPE_INDICATOR_FLOAT) { try { float fps = ByteBuffer.wrap(mdtaMetadataEntry.value).asFloatBuffer().get(); format = format.copyWithFrameRate(fps); format = format.copyWithMetadata(new Metadata(mdtaMetadataEntry)); } catch (NumberFormatException e) { Log.w(TAG, "Ignoring invalid framerate"); } } } } } return format; }
Example 6
Source File: EventLogger.java From GSYVideoPlayer with Apache License 2.0 | 5 votes |
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 |
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: GaplessInfoHolder.java From K-Sonic with MIT License | 5 votes |
/** * 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 9
Source File: SimpleExoPlayerView.java From K-Sonic with MIT License | 5 votes |
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 10
Source File: EventLogger.java From ExoPlayer-Offline with Apache License 2.0 | 5 votes |
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 |
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: EventLogger.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
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 13
Source File: ExoPlayerFragment.java From carstream-android-auto with Apache License 2.0 | 5 votes |
@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 14
Source File: EventLogger.java From K-Sonic with MIT License | 5 votes |
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 15
Source File: DefaultHlsExtractorFactory.java From MediaSDK with Apache License 2.0 | 5 votes |
/** 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 16
Source File: HlsSampleStreamWrapper.java From MediaSDK with Apache License 2.0 | 5 votes |
/** * 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 17
Source File: Mp3Extractor.java From MediaSDK with Apache License 2.0 | 5 votes |
@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; }
Example 18
Source File: EventLogger.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void printMetadata(Metadata metadata, String prefix) { for (int i = 0; i < metadata.length(); i++) { logd(prefix + metadata.get(i)); } }
Example 19
Source File: EventLogger.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void printMetadata(Metadata metadata, String prefix) { for (int i = 0; i < metadata.length(); i++) { logd(prefix + metadata.get(i)); } }
Example 20
Source File: EventLogger.java From MediaSDK with Apache License 2.0 | 4 votes |
private void printMetadata(Metadata metadata, String prefix) { for (int i = 0; i < metadata.length(); i++) { logd(prefix + metadata.get(i)); } }