Skip to content

Commit 4f233d2

Browse files
Googlerrohitjoins
authored andcommitted
Adds a null-check for getAdsManager()
PiperOrigin-RevId: 855313225 (cherry picked from commit 9286733)
1 parent 84788f8 commit 4f233d2

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

‎RELEASENOTES.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
* Bug fix: Corrected an issue where the ad MIME type did not match the
4242
MIME type provided in the IMA LOADED event. The fix now maps the ad MIME
4343
type using the ad pod index and ad position.
44+
* Add a null check before accessing result of `getAdsManager()`.
4445
* Session:
4546
* Fix bug where stopping a `MediaController` connected to a platform
4647
session crashed the app if stop happened during ad playback

‎libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/AdTagLoader.java‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,14 @@ private final class ComponentListener
14191419

14201420
@Override
14211421
public void onAdsManagerLoaded(AdsManagerLoadedEvent adsManagerLoadedEvent) {
1422-
AdsManager adsManager = adsManagerLoadedEvent.getAdsManager();
1422+
@Nullable AdsManager adsManager = adsManagerLoadedEvent.getAdsManager();
1423+
if (adsManager == null) {
1424+
// The same AdsLoader may be used for both Client-side ads and SSAI ads at the same time.
1425+
// In this scenario, it may emit an `AdsManagerLoadedEvent` which should be handled by the
1426+
// `ImaServerSideAdInsertionMediaSource` instead of the `AdTagLoader`. It's safe to ignore
1427+
// that event.
1428+
return;
1429+
}
14231430
if (!Objects.equals(pendingAdRequestContext, adsManagerLoadedEvent.getUserRequestContext())) {
14241431
adsManager.destroy();
14251432
return;

0 commit comments

Comments
 (0)