mirror of
https://github.com/androidx/media.git
synced 2025-05-07 15:40:37 +08:00
Add HlsMasterPlaylist.copy method
Creates a copy of this playlist which includes only the variants identified by the given variantUrls. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=163212562
This commit is contained in:
parent
9936bc6702
commit
bcc69c2da7
@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source.hls.playlist;
|
|||||||
|
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
import com.google.android.exoplayer2.util.MimeTypes;
|
import com.google.android.exoplayer2.util.MimeTypes;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -108,6 +109,20 @@ public final class HlsMasterPlaylist extends HlsPlaylist {
|
|||||||
? Collections.unmodifiableList(muxedCaptionFormats) : null;
|
? Collections.unmodifiableList(muxedCaptionFormats) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a copy of this playlist which includes only the renditions identified by the given
|
||||||
|
* urls.
|
||||||
|
*
|
||||||
|
* @param renditionUrls List of rendition urls.
|
||||||
|
* @return A copy of this playlist which includes only the renditions identified by the given
|
||||||
|
* urls.
|
||||||
|
*/
|
||||||
|
public HlsMasterPlaylist copy(List<String> renditionUrls) {
|
||||||
|
return new HlsMasterPlaylist(baseUri, tags, copyRenditionList(variants, renditionUrls),
|
||||||
|
copyRenditionList(audios, renditionUrls), copyRenditionList(subtitles, renditionUrls),
|
||||||
|
muxedAudioFormat, muxedCaptionFormats);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a playlist with a single variant.
|
* Creates a playlist with a single variant.
|
||||||
*
|
*
|
||||||
@ -121,4 +136,15 @@ public final class HlsMasterPlaylist extends HlsPlaylist {
|
|||||||
emptyList, null, null);
|
emptyList, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<HlsUrl> copyRenditionList(List<HlsUrl> variants, List<String> variantUrls) {
|
||||||
|
List<HlsUrl> copyVariants = new ArrayList<>();
|
||||||
|
for (int i = 0; i < variants.size(); i++) {
|
||||||
|
HlsUrl variant = variants.get(i);
|
||||||
|
if (variantUrls.contains(variant.url)) {
|
||||||
|
copyVariants.add(variant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return copyVariants;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user