From 497651c7b9b70ea4d84568506b88a9c682845fe6 Mon Sep 17 00:00:00 2001 From: aquilescanta Date: Mon, 23 Jan 2017 08:30:39 -0800 Subject: [PATCH] Ignore file extension for HLS Subtitle Renditions According to the spec, subtitle renditions must be Webvtt media segments. Issue:#2025 Issue:#2355 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=145289266 --- .../android/exoplayer2/source/hls/HlsMediaChunk.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaChunk.java b/library/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaChunk.java index 0c411854d55..7ef6b7ace0e 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaChunk.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaChunk.java @@ -187,7 +187,7 @@ public boolean isLoadCanceled() { public void load() throws IOException, InterruptedException { if (extractor == null && !isPackedAudio) { // See HLS spec, version 20, Section 3.4 for more information on packed audio extraction. - extractor = buildExtractorByExtension(); + extractor = createExtractor(); } maybeLoadInitData(); if (!loadCanceled) { @@ -329,11 +329,12 @@ private static DataSource buildDataSource(DataSource dataSource, byte[] encrypti return new Aes128DataSource(dataSource, encryptionKey, encryptionIv); } - private Extractor buildExtractorByExtension() { - // Set the extractor that will read the chunk. + private Extractor createExtractor() { + // Select the extractor that will read the chunk. Extractor extractor; boolean usingNewExtractor = true; - if (lastPathSegment.endsWith(WEBVTT_FILE_EXTENSION) + if (MimeTypes.TEXT_VTT.equals(hlsUrl.format.sampleMimeType) + || lastPathSegment.endsWith(WEBVTT_FILE_EXTENSION) || lastPathSegment.endsWith(VTT_FILE_EXTENSION)) { extractor = new WebvttExtractor(trackFormat.language, timestampAdjuster); } else if (!needNewExtractor) {