Search in sources :

Example 1 with Id3Frame

use of com.google.android.exoplayer2.metadata.id3.Id3Frame in project react-native-video by react-native-community.

the class VideoEventEmitter method timedMetadata.

void timedMetadata(Metadata metadata) {
    WritableArray metadataArray = Arguments.createArray();
    for (int i = 0; i < metadata.length(); i++) {
        Id3Frame frame = (Id3Frame) metadata.get(i);
        String value = "";
        if (frame instanceof TxxxFrame) {
            TxxxFrame txxxFrame = (TxxxFrame) frame;
            value = txxxFrame.value;
        }
        String identifier = frame.id;
        WritableMap map = Arguments.createMap();
        map.putString("identifier", identifier);
        map.putString("value", value);
        metadataArray.pushMap(map);
    }
    WritableMap event = Arguments.createMap();
    event.putArray(EVENT_PROP_TIMED_METADATA, metadataArray);
    receiveEvent(EVENT_TIMED_METADATA, event);
}
Also used : WritableMap(com.facebook.react.bridge.WritableMap) WritableArray(com.facebook.react.bridge.WritableArray) TxxxFrame(com.google.android.exoplayer2.metadata.id3.TxxxFrame) Id3Frame(com.google.android.exoplayer2.metadata.id3.Id3Frame)

Example 2 with Id3Frame

use of com.google.android.exoplayer2.metadata.id3.Id3Frame in project ExoPlayer by google.

the class MetadataUtil method parseUint8Attribute.

private static Id3Frame parseUint8Attribute(int type, String id, ParsableByteArray data, boolean isTextInformationFrame, boolean isBoolean) {
    int value = parseUint8AttributeValue(data);
    if (isBoolean) {
        value = Math.min(1, value);
    }
    if (value >= 0) {
        return isTextInformationFrame ? new TextInformationFrame(id, null, Integer.toString(value)) : new CommentFrame(LANGUAGE_UNDEFINED, id, Integer.toString(value));
    }
    Log.w(TAG, "Failed to parse uint8 attribute: " + Atom.getAtomTypeString(type));
    return null;
}
Also used : CommentFrame(com.google.android.exoplayer2.metadata.id3.CommentFrame) TextInformationFrame(com.google.android.exoplayer2.metadata.id3.TextInformationFrame)

Example 3 with Id3Frame

use of com.google.android.exoplayer2.metadata.id3.Id3Frame in project android-player-samples by BrightcoveOS.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    brightcoveVideoView.getEventEmitter().on(EventType.DID_SET_SOURCE, new EventListener() {

        @Override
        public void processEvent(Event event) {
            ExoPlayerVideoDisplayComponent exoPlayerVideoDisplayComponent = (ExoPlayerVideoDisplayComponent) brightcoveVideoView.getVideoDisplay();
            exoPlayerVideoDisplayComponent.setMetadataListener(new ExoPlayerVideoDisplayComponent.Id3MetadataListener() {

                @Override
                public void onId3Metadata(List<Id3Frame> list) {
                    for (Id3Frame id3Frame : list) {
                        Log.v(TAG, "id3 Frame id: " + id3Frame.id);
                    }
                }
            });
        }
    });
    Video video = Video.createVideo("https://s3.amazonaws.com/as-zencoder/hls-timed-metadata/test.m3u8");
    brightcoveVideoView.add(video);
    brightcoveVideoView.start();
    // Log whether or not instance state in non-null.
    if (savedInstanceState != null) {
        Log.v(TAG, "Restoring saved position");
    } else {
        Log.v(TAG, "No saved state");
    }
}
Also used : Video(com.brightcove.player.model.Video) Event(com.brightcove.player.event.Event) List(java.util.List) EventListener(com.brightcove.player.event.EventListener) Id3Frame(com.google.android.exoplayer.metadata.id3.Id3Frame) ExoPlayerVideoDisplayComponent(com.brightcove.player.display.ExoPlayerVideoDisplayComponent)

Example 4 with Id3Frame

use of com.google.android.exoplayer2.metadata.id3.Id3Frame in project ExoPlayer by google.

the class Id3Decoder method decode.

/**
   * 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);
}
Also used : ParsableByteArray(com.google.android.exoplayer2.util.ParsableByteArray) ArrayList(java.util.ArrayList) Metadata(com.google.android.exoplayer2.metadata.Metadata)

Example 5 with Id3Frame

use of com.google.android.exoplayer2.metadata.id3.Id3Frame in project ExoPlayer by google.

the class EventLogger method printMetadata.

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));
        }
    }
}
Also used : GeobFrame(com.google.android.exoplayer2.metadata.id3.GeobFrame) EventMessage(com.google.android.exoplayer2.metadata.emsg.EventMessage) ApicFrame(com.google.android.exoplayer2.metadata.id3.ApicFrame) Metadata(com.google.android.exoplayer2.metadata.Metadata) CommentFrame(com.google.android.exoplayer2.metadata.id3.CommentFrame) UrlLinkFrame(com.google.android.exoplayer2.metadata.id3.UrlLinkFrame) PrivFrame(com.google.android.exoplayer2.metadata.id3.PrivFrame) Id3Frame(com.google.android.exoplayer2.metadata.id3.Id3Frame) TextInformationFrame(com.google.android.exoplayer2.metadata.id3.TextInformationFrame)

Aggregations

Id3Frame (com.google.android.exoplayer.metadata.id3.Id3Frame)2 Metadata (com.google.android.exoplayer2.metadata.Metadata)2 CommentFrame (com.google.android.exoplayer2.metadata.id3.CommentFrame)2 Id3Frame (com.google.android.exoplayer2.metadata.id3.Id3Frame)2 TextInformationFrame (com.google.android.exoplayer2.metadata.id3.TextInformationFrame)2 ExoPlayerVideoDisplayComponent (com.brightcove.player.display.ExoPlayerVideoDisplayComponent)1 Event (com.brightcove.player.event.Event)1 EventListener (com.brightcove.player.event.EventListener)1 Video (com.brightcove.player.model.Video)1 WritableArray (com.facebook.react.bridge.WritableArray)1 WritableMap (com.facebook.react.bridge.WritableMap)1 GeobFrame (com.google.android.exoplayer.metadata.id3.GeobFrame)1 PrivFrame (com.google.android.exoplayer.metadata.id3.PrivFrame)1 TxxxFrame (com.google.android.exoplayer.metadata.id3.TxxxFrame)1 EventMessage (com.google.android.exoplayer2.metadata.emsg.EventMessage)1 ApicFrame (com.google.android.exoplayer2.metadata.id3.ApicFrame)1 GeobFrame (com.google.android.exoplayer2.metadata.id3.GeobFrame)1 PrivFrame (com.google.android.exoplayer2.metadata.id3.PrivFrame)1 TxxxFrame (com.google.android.exoplayer2.metadata.id3.TxxxFrame)1 UrlLinkFrame (com.google.android.exoplayer2.metadata.id3.UrlLinkFrame)1