Search in sources :

Example 11 with TracksInfo

use of com.google.android.exoplayer2.TracksInfo in project ExoPlayer by google.

the class StyledPlayerControlView method gatherSupportedTrackInfosOfType.

private ImmutableList<TrackInformation> gatherSupportedTrackInfosOfType(TracksInfo tracksInfo, @C.TrackType int trackType) {
    ImmutableList.Builder<TrackInformation> tracks = new ImmutableList.Builder<>();
    List<TrackGroupInfo> trackGroupInfos = tracksInfo.getTrackGroupInfos();
    for (int trackGroupIndex = 0; trackGroupIndex < trackGroupInfos.size(); trackGroupIndex++) {
        TrackGroupInfo trackGroupInfo = trackGroupInfos.get(trackGroupIndex);
        if (trackGroupInfo.getTrackType() != trackType) {
            continue;
        }
        TrackGroup trackGroup = trackGroupInfo.getTrackGroup();
        for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
            if (!trackGroupInfo.isTrackSupported(trackIndex)) {
                continue;
            }
            String trackName = trackNameProvider.getTrackName(trackGroup.getFormat(trackIndex));
            tracks.add(new TrackInformation(tracksInfo, trackGroupIndex, trackIndex, trackName));
        }
    }
    return tracks.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) TrackGroup(com.google.android.exoplayer2.source.TrackGroup) TrackGroupInfo(com.google.android.exoplayer2.TracksInfo.TrackGroupInfo) SuppressLint(android.annotation.SuppressLint)

Aggregations

TrackGroup (com.google.android.exoplayer2.source.TrackGroup)7 TracksInfo (com.google.android.exoplayer2.TracksInfo)6 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)4 Test (org.junit.Test)4 TrackGroupInfo (com.google.android.exoplayer2.TracksInfo.TrackGroupInfo)2 TrackSelectionArray (com.google.android.exoplayer2.trackselection.TrackSelectionArray)2 ImmutableList (com.google.common.collect.ImmutableList)2 NullableType (org.checkerframework.checker.nullness.compatqual.NullableType)2 SuppressLint (android.annotation.SuppressLint)1 Nullable (androidx.annotation.Nullable)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 FormatSupport (com.google.android.exoplayer2.C.FormatSupport)1 RendererCapabilities (com.google.android.exoplayer2.RendererCapabilities)1 AdaptiveSupport (com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport)1 Capabilities (com.google.android.exoplayer2.RendererCapabilities.Capabilities)1 AnalyticsListener (com.google.android.exoplayer2.analytics.AnalyticsListener)1 EventTime (com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime)1 SinglePeriodTimeline (com.google.android.exoplayer2.source.SinglePeriodTimeline)1 ActionSchedule (com.google.android.exoplayer2.testutil.ActionSchedule)1 PlayerRunnable (com.google.android.exoplayer2.testutil.ActionSchedule.PlayerRunnable)1