com.google.android.exoplayer2.metadata.Metadata Java Examples
The following examples show how to use
com.google.android.exoplayer2.metadata.Metadata.
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: FlacStreamMetadata.java From MediaSDK with Apache License 2.0 | 6 votes |
@Nullable private static Metadata buildMetadata( List<String> vorbisComments, List<PictureFrame> pictureFrames) { if (vorbisComments.isEmpty() && pictureFrames.isEmpty()) { return null; } ArrayList<Metadata.Entry> metadataEntries = new ArrayList<>(); for (int i = 0; i < vorbisComments.size(); i++) { String vorbisComment = vorbisComments.get(i); String[] keyAndValue = Util.splitAtFirst(vorbisComment, SEPARATOR); if (keyAndValue.length != 2) { Log.w(TAG, "Failed to parse vorbis comment: " + vorbisComment); } else { VorbisComment entry = new VorbisComment(keyAndValue[0], keyAndValue[1]); metadataEntries.add(entry); } } metadataEntries.addAll(pictureFrames); return metadataEntries.isEmpty() ? null : new Metadata(metadataEntries); }
Example #2
Source File: AtomParsers.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Parses a udta atom. * * @param udtaAtom The udta (user data) atom to decode. * @param isQuickTime True for QuickTime media. False otherwise. * @return Parsed metadata, or null. */ public static Metadata parseUdta(Atom.LeafAtom udtaAtom, boolean isQuickTime) { if (isQuickTime) { // Meta boxes are regular boxes rather than full boxes in QuickTime. For now, don't try and // decode one. return null; } ParsableByteArray udtaData = udtaAtom.data; udtaData.setPosition(Atom.HEADER_SIZE); while (udtaData.bytesLeft() >= Atom.HEADER_SIZE) { int atomPosition = udtaData.getPosition(); int atomSize = udtaData.readInt(); int atomType = udtaData.readInt(); if (atomType == Atom.TYPE_meta) { udtaData.setPosition(atomPosition); return parseMetaAtom(udtaData, atomPosition + atomSize); } udtaData.skipBytes(atomSize - Atom.HEADER_SIZE); } return null; }
Example #3
Source File: IcyDecoder.java From MediaSDK with Apache License 2.0 | 6 votes |
@VisibleForTesting /* package */ Metadata decode(String metadata) { @Nullable String name = null; @Nullable String url = null; int index = 0; Matcher matcher = METADATA_ELEMENT.matcher(metadata); while (matcher.find(index)) { String key = Util.toLowerInvariant(matcher.group(1)); String value = matcher.group(2); switch (key) { case STREAM_KEY_NAME: name = value; break; case STREAM_KEY_URL: url = value; break; } index = matcher.end(); } return new Metadata(new IcyInfo(metadata, name, url)); }
Example #4
Source File: AtomParsers.java From K-Sonic with MIT License | 6 votes |
/** * Parses a udta atom. * * @param udtaAtom The udta (user data) atom to decode. * @param isQuickTime True for QuickTime media. False otherwise. * @return Parsed metadata, or null. */ public static Metadata parseUdta(Atom.LeafAtom udtaAtom, boolean isQuickTime) { if (isQuickTime) { // Meta boxes are regular boxes rather than full boxes in QuickTime. For now, don't try and // decode one. return null; } ParsableByteArray udtaData = udtaAtom.data; udtaData.setPosition(Atom.HEADER_SIZE); while (udtaData.bytesLeft() >= Atom.HEADER_SIZE) { int atomPosition = udtaData.getPosition(); int atomSize = udtaData.readInt(); int atomType = udtaData.readInt(); if (atomType == Atom.TYPE_meta) { udtaData.setPosition(atomPosition); return parseMetaAtom(udtaData, atomPosition + atomSize); } udtaData.skipBytes(atomSize - Atom.HEADER_SIZE); } return null; }
Example #5
Source File: AtomParsers.java From MediaSDK with Apache License 2.0 | 6 votes |
/** * Parses a udta atom. * * @param udtaAtom The udta (user data) atom to decode. * @param isQuickTime True for QuickTime media. False otherwise. * @return Parsed metadata, or null. */ @Nullable public static Metadata parseUdta(Atom.LeafAtom udtaAtom, boolean isQuickTime) { if (isQuickTime) { // Meta boxes are regular boxes rather than full boxes in QuickTime. For now, don't try and // decode one. return null; } ParsableByteArray udtaData = udtaAtom.data; udtaData.setPosition(Atom.HEADER_SIZE); while (udtaData.bytesLeft() >= Atom.HEADER_SIZE) { int atomPosition = udtaData.getPosition(); int atomSize = udtaData.readInt(); int atomType = udtaData.readInt(); if (atomType == Atom.TYPE_meta) { udtaData.setPosition(atomPosition); return parseUdtaMeta(udtaData, atomPosition + atomSize); } udtaData.setPosition(atomPosition + atomSize); } return null; }
Example #6
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 #7
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 #8
Source File: AtomParsers.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
/** * Parses a udta atom. * * @param udtaAtom The udta (user data) atom to decode. * @param isQuickTime True for QuickTime media. False otherwise. * @return Parsed metadata, or null. */ public static Metadata parseUdta(Atom.LeafAtom udtaAtom, boolean isQuickTime) { if (isQuickTime) { // Meta boxes are regular boxes rather than full boxes in QuickTime. For now, don't try and // decode one. return null; } ParsableByteArray udtaData = udtaAtom.data; udtaData.setPosition(Atom.HEADER_SIZE); while (udtaData.bytesLeft() >= Atom.HEADER_SIZE) { int atomPosition = udtaData.getPosition(); int atomSize = udtaData.readInt(); int atomType = udtaData.readInt(); if (atomType == Atom.TYPE_meta) { udtaData.setPosition(atomPosition); return parseMetaAtom(udtaData, atomPosition + atomSize); } udtaData.skipBytes(atomSize - Atom.HEADER_SIZE); } return null; }
Example #9
Source File: CommentAndPostRecyclerViewAdapter.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 5 votes |
@Override public void initialize(@NonNull Container container, @NonNull PlaybackInfo playbackInfo) { if (helper == null) { helper = new ExoPlayerViewHelper(this, mediaUri, null, mExoCreator); helper.addEventListener(new Playable.EventListener() { @Override public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) { if (!trackGroups.isEmpty()) { for (int i = 0; i < trackGroups.length; i++) { String mimeType = trackGroups.get(i).getFormat(0).sampleMimeType; if (mimeType != null && mimeType.contains("audio")) { helper.setVolume(volume); muteButton.setVisibility(View.VISIBLE); if (volume != 0f) { muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_18dp)); } else { muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_18dp)); } break; } } } else { muteButton.setVisibility(View.GONE); } } @Override public void onMetadata(Metadata metadata) { } @Override public void onCues(List<Cue> cues) { } }); } helper.initialize(container, playbackInfo); }
Example #10
Source File: Format.java From K-Sonic with MIT License | 5 votes |
Format(String id, String containerMimeType, String sampleMimeType, String codecs, int bitrate, int maxInputSize, int width, int height, float frameRate, int rotationDegrees, float pixelWidthHeightRatio, byte[] projectionData, @C.StereoMode int stereoMode, int channelCount, int sampleRate, @C.PcmEncoding int pcmEncoding, int encoderDelay, int encoderPadding, @C.SelectionFlags int selectionFlags, String language, int accessibilityChannel, long subsampleOffsetUs, List<byte[]> initializationData, DrmInitData drmInitData, Metadata metadata) { this.id = id; this.containerMimeType = containerMimeType; this.sampleMimeType = sampleMimeType; this.codecs = codecs; this.bitrate = bitrate; this.maxInputSize = maxInputSize; this.width = width; this.height = height; this.frameRate = frameRate; this.rotationDegrees = rotationDegrees; this.pixelWidthHeightRatio = pixelWidthHeightRatio; this.projectionData = projectionData; this.stereoMode = stereoMode; this.channelCount = channelCount; this.sampleRate = sampleRate; this.pcmEncoding = pcmEncoding; this.encoderDelay = encoderDelay; this.encoderPadding = encoderPadding; this.selectionFlags = selectionFlags; this.language = language; this.accessibilityChannel = accessibilityChannel; this.subsampleOffsetUs = subsampleOffsetUs; this.initializationData = initializationData == null ? Collections.<byte[]>emptyList() : initializationData; this.drmInitData = drmInitData; this.metadata = metadata; }
Example #11
Source File: PostRecyclerViewAdapter.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 5 votes |
@Override public void initialize(@NonNull Container container, @NonNull PlaybackInfo playbackInfo) { if (helper == null) { helper = new ExoPlayerViewHelper(this, mediaUri, null, mExoCreator); helper.addEventListener(new Playable.EventListener() { @Override public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) { if (!trackGroups.isEmpty()) { for (int i = 0; i < trackGroups.length; i++) { String mimeType = trackGroups.get(i).getFormat(0).sampleMimeType; if (mimeType != null && mimeType.contains("audio")) { helper.setVolume(volume); muteButton.setVisibility(View.VISIBLE); if (volume != 0f) { muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_unmute_white_rounded_18dp)); } else { muteButton.setImageDrawable(mActivity.getDrawable(R.drawable.ic_mute_white_rounded_18dp)); } break; } } } else { muteButton.setVisibility(View.GONE); } } @Override public void onMetadata(Metadata metadata) { } @Override public void onCues(List<Cue> cues) { } }); } helper.initialize(container, playbackInfo); }
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: AtomParsers.java From K-Sonic with MIT License | 5 votes |
private static Metadata parseMetaAtom(ParsableByteArray meta, int limit) { meta.skipBytes(Atom.FULL_HEADER_SIZE); while (meta.getPosition() < limit) { int atomPosition = meta.getPosition(); int atomSize = meta.readInt(); int atomType = meta.readInt(); if (atomType == Atom.TYPE_ilst) { meta.setPosition(atomPosition); return parseIlst(meta, atomPosition + atomSize); } meta.skipBytes(atomSize - Atom.HEADER_SIZE); } return null; }
Example #14
Source File: Format.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("ResourceType") /* package */ Format(Parcel in) { id = in.readString(); label = in.readString(); containerMimeType = in.readString(); sampleMimeType = in.readString(); codecs = in.readString(); bitrate = in.readInt(); maxInputSize = in.readInt(); width = in.readInt(); height = in.readInt(); frameRate = in.readFloat(); rotationDegrees = in.readInt(); pixelWidthHeightRatio = in.readFloat(); boolean hasProjectionData = Util.readBoolean(in); projectionData = hasProjectionData ? in.createByteArray() : null; stereoMode = in.readInt(); colorInfo = in.readParcelable(ColorInfo.class.getClassLoader()); channelCount = in.readInt(); sampleRate = in.readInt(); pcmEncoding = in.readInt(); encoderDelay = in.readInt(); encoderPadding = in.readInt(); selectionFlags = in.readInt(); language = in.readString(); accessibilityChannel = in.readInt(); subsampleOffsetUs = in.readLong(); int initializationDataSize = in.readInt(); initializationData = new ArrayList<>(initializationDataSize); for (int i = 0; i < initializationDataSize; i++) { initializationData.add(in.createByteArray()); } drmInitData = in.readParcelable(DrmInitData.class.getClassLoader()); metadata = in.readParcelable(Metadata.class.getClassLoader()); }
Example #15
Source File: AnalyticsCollector.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
@Override public final void onMetadata(Metadata metadata) { EventTime eventTime = generatePlayingMediaPeriodEventTime(); for (AnalyticsListener listener : listeners) { listener.onMetadata(eventTime, metadata); } }
Example #16
Source File: Format.java From K-Sonic with MIT License | 5 votes |
public Format copyWithMetadata(Metadata metadata) { return new Format(id, containerMimeType, sampleMimeType, codecs, bitrate, maxInputSize, width, height, frameRate, rotationDegrees, pixelWidthHeightRatio, projectionData, stereoMode, channelCount, sampleRate, pcmEncoding, encoderDelay, encoderPadding, selectionFlags, language, accessibilityChannel, subsampleOffsetUs, initializationData, drmInitData, metadata); }
Example #17
Source File: Id3Decoder.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Decodes ID3 tags. * * @param data The bytes to decode ID3 tags from. * @param size Amount of bytes in {@code data} to read. * @return A {@link Metadata} object containing the decoded ID3 tags, or null if the data could * not be decoded. */ public @Nullable Metadata decode(byte[] data, int size) { List<Id3Frame> id3Frames = new ArrayList<>(); ParsableByteArray id3Data = new ParsableByteArray(data, size); Id3Header id3Header = decodeHeader(id3Data); if (id3Header == null) { return null; } int startPosition = id3Data.getPosition(); int frameHeaderSize = id3Header.majorVersion == 2 ? 6 : 10; int framesSize = id3Header.framesSize; if (id3Header.isUnsynchronized) { framesSize = removeUnsynchronization(id3Data, id3Header.framesSize); } id3Data.setLimit(startPosition + framesSize); boolean unsignedIntFrameSizeHack = false; if (!validateFrames(id3Data, id3Header.majorVersion, frameHeaderSize, false)) { if (id3Header.majorVersion == 4 && validateFrames(id3Data, 4, frameHeaderSize, true)) { unsignedIntFrameSizeHack = true; } else { Log.w(TAG, "Failed to validate ID3 tag with majorVersion=" + id3Header.majorVersion); return null; } } while (id3Data.bytesLeft() >= frameHeaderSize) { Id3Frame frame = decodeFrame(id3Header.majorVersion, id3Data, unsignedIntFrameSizeHack, frameHeaderSize, framePredicate); if (frame != null) { id3Frames.add(frame); } } return new Metadata(id3Frames); }
Example #18
Source File: PlayerEmsgHandler.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
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 #19
Source File: FlacExtractor.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Peeks ID3 tag data (if present) at the beginning of the input. * * @return The first ID3 tag decoded into a {@link Metadata} object. May be null if ID3 tag is not * present in the input. */ @Nullable private Metadata peekId3Data(ExtractorInput input) throws IOException, InterruptedException { input.resetPeekPosition(); Id3Decoder.FramePredicate id3FramePredicate = isId3MetadataDisabled ? Id3Decoder.NO_FRAMES_PREDICATE : null; return id3Peeker.peekId3Data(input, id3FramePredicate); }
Example #20
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 #21
Source File: Id3Peeker.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Peeks ID3 data from the input and parses the first ID3 tag. * * @param input The {@link ExtractorInput} from which data should be peeked. * @param id3FramePredicate Determines which ID3 frames are decoded. May be null to decode all * frames. * @return The first ID3 tag decoded into a {@link Metadata} object. May be null if ID3 tag is not * present in the input. * @throws IOException If an error occurred peeking from the input. * @throws InterruptedException If the thread was interrupted. */ @Nullable public Metadata peekId3Data( ExtractorInput input, @Nullable Id3Decoder.FramePredicate id3FramePredicate) throws IOException, InterruptedException { int peekedId3Bytes = 0; Metadata metadata = null; while (true) { try { input.peekFully(scratch.data, 0, Id3Decoder.ID3_HEADER_LENGTH); } catch (EOFException e) { // If input has less than ID3_HEADER_LENGTH, ignore the rest. break; } scratch.setPosition(0); if (scratch.readUnsignedInt24() != Id3Decoder.ID3_TAG) { // Not an ID3 tag. break; } scratch.skipBytes(3); // Skip major version, minor version and flags. int framesLength = scratch.readSynchSafeInt(); int tagLength = Id3Decoder.ID3_HEADER_LENGTH + framesLength; if (metadata == null) { byte[] id3Data = new byte[tagLength]; System.arraycopy(scratch.data, 0, id3Data, 0, Id3Decoder.ID3_HEADER_LENGTH); input.peekFully(id3Data, Id3Decoder.ID3_HEADER_LENGTH, framesLength); metadata = new Id3Decoder(id3FramePredicate).decode(id3Data, tagLength); } else { input.advancePeekPosition(framesLength); } peekedId3Bytes += tagLength; } input.resetPeekPosition(); input.advancePeekPosition(peekedId3Bytes); return metadata; }
Example #22
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 #23
Source File: EventLogger.java From mimi-reader 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 #24
Source File: PlayerEmsgHandler.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
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 #25
Source File: Id3Decoder.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
/** * Decodes ID3 tags. * * @param data The bytes to decode ID3 tags from. * @param size Amount of bytes in {@code data} to read. * @return A {@link Metadata} object containing the decoded ID3 tags, or null if the data could * not be decoded. */ public @Nullable Metadata decode(byte[] data, int size) { List<Id3Frame> id3Frames = new ArrayList<>(); ParsableByteArray id3Data = new ParsableByteArray(data, size); Id3Header id3Header = decodeHeader(id3Data); if (id3Header == null) { return null; } int startPosition = id3Data.getPosition(); int frameHeaderSize = id3Header.majorVersion == 2 ? 6 : 10; int framesSize = id3Header.framesSize; if (id3Header.isUnsynchronized) { framesSize = removeUnsynchronization(id3Data, id3Header.framesSize); } id3Data.setLimit(startPosition + framesSize); boolean unsignedIntFrameSizeHack = false; if (!validateFrames(id3Data, id3Header.majorVersion, frameHeaderSize, false)) { if (id3Header.majorVersion == 4 && validateFrames(id3Data, 4, frameHeaderSize, true)) { unsignedIntFrameSizeHack = true; } else { Log.w(TAG, "Failed to validate ID3 tag with majorVersion=" + id3Header.majorVersion); return null; } } while (id3Data.bytesLeft() >= frameHeaderSize) { Id3Frame frame = decodeFrame(id3Header.majorVersion, id3Data, unsignedIntFrameSizeHack, frameHeaderSize, framePredicate); if (frame != null) { id3Frames.add(frame); } } return new Metadata(id3Frames); }
Example #26
Source File: AtomParsers.java From K-Sonic with MIT License | 5 votes |
private static Metadata parseIlst(ParsableByteArray ilst, int limit) { ilst.skipBytes(Atom.HEADER_SIZE); ArrayList<Metadata.Entry> entries = new ArrayList<>(); while (ilst.getPosition() < limit) { Metadata.Entry entry = MetadataUtil.parseIlstElement(ilst); if (entry != null) { entries.add(entry); } } return entries.isEmpty() ? null : new Metadata(entries); }
Example #27
Source File: Id3Decoder.java From K-Sonic with MIT License | 5 votes |
/** * Decodes ID3 tags. * * @param data The bytes to decode ID3 tags from. * @param size Amount of bytes in {@code data} to read. * @return A {@link Metadata} object containing the decoded ID3 tags. */ public Metadata decode(byte[] data, int size) { List<Id3Frame> id3Frames = new ArrayList<>(); ParsableByteArray id3Data = new ParsableByteArray(data, size); Id3Header id3Header = decodeHeader(id3Data); if (id3Header == null) { return null; } int startPosition = id3Data.getPosition(); int framesSize = id3Header.framesSize; if (id3Header.isUnsynchronized) { framesSize = removeUnsynchronization(id3Data, id3Header.framesSize); } id3Data.setLimit(startPosition + framesSize); boolean unsignedIntFrameSizeHack = false; if (id3Header.majorVersion == 4) { if (!validateV4Frames(id3Data, false)) { if (validateV4Frames(id3Data, true)) { unsignedIntFrameSizeHack = true; } else { Log.w(TAG, "Failed to validate V4 ID3 tag"); return null; } } } int frameHeaderSize = id3Header.majorVersion == 2 ? 6 : 10; while (id3Data.bytesLeft() >= frameHeaderSize) { Id3Frame frame = decodeFrame(id3Header.majorVersion, id3Data, unsignedIntFrameSizeHack, frameHeaderSize, framePredicate); if (frame != null) { id3Frames.add(frame); } } return new Metadata(id3Frames); }
Example #28
Source File: AtomParsers.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static Metadata parseIlst(ParsableByteArray ilst, int limit) { ilst.skipBytes(Atom.HEADER_SIZE); ArrayList<Metadata.Entry> entries = new ArrayList<>(); while (ilst.getPosition() < limit) { Metadata.Entry entry = MetadataUtil.parseIlstElement(ilst); if (entry != null) { entries.add(entry); } } return entries.isEmpty() ? null : new Metadata(entries); }
Example #29
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 #30
Source File: ExoVideoView.java From ExoVideoView with Apache License 2.0 | 5 votes |
private void updateForCurrentTrackSelections() { if (player == null) { return; } TrackSelectionArray selections = player.getCurrentTrackSelections(); for (int i = 0; i < selections.length; i++) { if (player.getRendererType(i) == C.TRACK_TYPE_VIDEO && selections.get(i) != null) { // Video enabled so artwork must be hidden. If the shutter is closed, it will be opened in // onRenderedFirstFrame(). hideArtwork(); return; } } // Video disabled so the shutter must be closed. if (shutterView != null) { shutterView.setVisibility(VISIBLE); } // Display artwork if enabled and available, else hide it. if (useArtwork) { for (int i = 0; i < selections.length; i++) { TrackSelection selection = selections.get(i); if (selection != null) { for (int j = 0; j < selection.length(); j++) { Metadata metadata = selection.getFormat(j).metadata; if (metadata != null && setArtworkFromMetadata(metadata)) { return; } } } } if (setArtworkFromBitmap(defaultArtwork)) { return; } } // Artwork disabled or unavailable. hideArtwork(); }