mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Prevent NPE in ImaAdsLoader onPositionDiscontinuity.
Any seek before the first timeline becomes available will result in a NPE. Change it to handle that case gracefully. Issue:#5831 PiperOrigin-RevId: 264603061
This commit is contained in:
parent
6a1331f125
commit
51476fa2c8
1 changed files with 4 additions and 4 deletions
|
|
@ -484,6 +484,7 @@ public final class ImaAdsLoader
|
||||||
pendingContentPositionMs = C.TIME_UNSET;
|
pendingContentPositionMs = C.TIME_UNSET;
|
||||||
adGroupIndex = C.INDEX_UNSET;
|
adGroupIndex = C.INDEX_UNSET;
|
||||||
contentDurationMs = C.TIME_UNSET;
|
contentDurationMs = C.TIME_UNSET;
|
||||||
|
timeline = Timeline.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -966,7 +967,7 @@ public final class ImaAdsLoader
|
||||||
if (contentDurationUs != C.TIME_UNSET) {
|
if (contentDurationUs != C.TIME_UNSET) {
|
||||||
adPlaybackState = adPlaybackState.withContentDurationUs(contentDurationUs);
|
adPlaybackState = adPlaybackState.withContentDurationUs(contentDurationUs);
|
||||||
}
|
}
|
||||||
updateImaStateForPlayerState();
|
onPositionDiscontinuity(Player.DISCONTINUITY_REASON_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1021,7 +1022,7 @@ public final class ImaAdsLoader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateAdPlaybackState();
|
updateAdPlaybackState();
|
||||||
} else {
|
} else if (!timeline.isEmpty()) {
|
||||||
long positionMs = player.getCurrentPosition();
|
long positionMs = player.getCurrentPosition();
|
||||||
timeline.getPeriod(0, period);
|
timeline.getPeriod(0, period);
|
||||||
int newAdGroupIndex = period.getAdGroupIndexForPositionUs(C.msToUs(positionMs));
|
int newAdGroupIndex = period.getAdGroupIndexForPositionUs(C.msToUs(positionMs));
|
||||||
|
|
@ -1033,9 +1034,8 @@ public final class ImaAdsLoader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
updateImaStateForPlayerState();
|
|
||||||
}
|
}
|
||||||
|
updateImaStateForPlayerState();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Internal methods.
|
// Internal methods.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue