Commit 4fec2429 by andrewlewis Committed by Oliver Woodman

Fix handling of ad tags where ad groups are out of order

IMA's cue points may not be in order, so sort them. It looks like IMA events use
time ordered ad indices, so it is not necessary to map between the original cue
point order and the time order.

Issue: #3716

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=185495798
parent 3ec96aee
...@@ -88,6 +88,8 @@ ...@@ -88,6 +88,8 @@
* Add support for playing non-Extractor content MediaSources in * Add support for playing non-Extractor content MediaSources in
the IMA demo app the IMA demo app
([#3676](https://github.com/google/ExoPlayer/issues/3676)). ([#3676](https://github.com/google/ExoPlayer/issues/3676)).
* Fix handling of ad tags where ad groups are out of order
([#3716](https://github.com/google/ExoPlayer/issues/3716)).
* `EventLogger` moved from the demo app into the core library. * `EventLogger` moved from the demo app into the core library.
* Fix ANR issue on Huawei P8 Lite * Fix ANR issue on Huawei P8 Lite
([#3724](https://github.com/google/ExoPlayer/issues/3724)). ([#3724](https://github.com/google/ExoPlayer/issues/3724)).
......
...@@ -970,11 +970,17 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A ...@@ -970,11 +970,17 @@ public final class ImaAdsLoader extends Player.DefaultEventListener implements A
int count = cuePoints.size(); int count = cuePoints.size();
long[] adGroupTimesUs = new long[count]; long[] adGroupTimesUs = new long[count];
int adGroupIndex = 0;
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
double cuePoint = cuePoints.get(i); double cuePoint = cuePoints.get(i);
adGroupTimesUs[i] = if (cuePoint == -1.0) {
cuePoint == -1.0 ? C.TIME_END_OF_SOURCE : (long) (C.MICROS_PER_SECOND * cuePoint); adGroupTimesUs[count - 1] = C.TIME_END_OF_SOURCE;
} else {
adGroupTimesUs[adGroupIndex++] = (long) (C.MICROS_PER_SECOND * cuePoint);
}
} }
// Cue points may be out of order, so sort them.
Arrays.sort(adGroupTimesUs, 0, adGroupIndex);
return adGroupTimesUs; return adGroupTimesUs;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment