From 326ec967af0ac5782b0b979b7012ca2ae6faea70 Mon Sep 17 00:00:00 2001 From: andrewlewis Date: Mon, 15 Feb 2021 16:25:14 +0000 Subject: [PATCH] Fix ad tag loader period index Previously it was safe to query the first period in the timeline, but now we support using the ads loader in concatenations we need to use the current period index instead. PiperOrigin-RevId: 357578003 --- RELEASENOTES.md | 4 ++++ .../com/google/android/exoplayer2/ext/ima/AdTagLoader.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 967f28bca9..498953995d 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -7,6 +7,10 @@ * Audio: * Fix `SimpleExoPlayer` reporting audio session ID as 0 in some cases ([#8585](https://github.com/google/ExoPlayer/issues/8585)). +* IMA extension: + * Fix a bug with playback of ads in playlists, where the incorrect period + index was used when deciding whether to trigger playback of an ad after + a seek. * VP9 extension: Update to use NDK r22 ([#8581](https://github.com/google/ExoPlayer/issues/8581)). * FLAC extension: Update to use NDK r22 diff --git a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/AdTagLoader.java b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/AdTagLoader.java index 9908e4940c..3984d586df 100644 --- a/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/AdTagLoader.java +++ b/extensions/ima/src/main/java/com/google/android/exoplayer2/ext/ima/AdTagLoader.java @@ -826,7 +826,7 @@ import java.util.Map; ensureSentContentCompleteIfAtEndOfStream(); if (!sentContentComplete && !timeline.isEmpty()) { long positionMs = getContentPeriodPositionMs(player, timeline, period); - timeline.getPeriod(/* periodIndex= */ 0, period); + timeline.getPeriod(player.getCurrentPeriodIndex(), period); int newAdGroupIndex = period.getAdGroupIndexForPositionUs(C.msToUs(positionMs)); if (newAdGroupIndex != C.INDEX_UNSET) { sentPendingContentPositionMs = false;