Skip to content

Commit

Permalink
Allow apps to add a VideoAdPlayerCallback
Browse files Browse the repository at this point in the history
Issue: #7944
PiperOrigin-RevId: 335012643
  • Loading branch information
andrewlewis authored and kim-vde committed Oct 6, 2020
1 parent 067712f commit 41192ee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
* IMA extension:
* Fix position reporting after fetch errors
([#7956](https://github.com/google/ExoPlayer/issues/7956)).
* Allow apps to specify a `VideoAdPlayerCallback`
([#7944](https://github.com/google/ExoPlayer/issues/7944)).

### 2.12.0 (2020-09-11) ###

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public static final class Builder {
@Nullable private ImaSdkSettings imaSdkSettings;
@Nullable private AdErrorListener adErrorListener;
@Nullable private AdEventListener adEventListener;
@Nullable private VideoAdPlayer.VideoAdPlayerCallback videoAdPlayerCallback;
@Nullable private Set<UiElement> adUiElements;
@Nullable private Collection<CompanionAdSlot> companionAdSlots;
private long adPreloadTimeoutMs;
Expand Down Expand Up @@ -190,6 +191,22 @@ public Builder setAdEventListener(AdEventListener adEventListener) {
return this;
}

/**
* Sets a callback to receive video ad player events. Note that these events are handled
* internally by the IMA SDK and this ads loader. For analytics and diagnostics, new
* implementations should generally use events from the top-level {@link Player} listeners
* instead of setting a callback via this method.
*
* @param videoAdPlayerCallback The callback to receive video ad player events.
* @return This builder, for convenience.
* @see com.google.ads.interactivemedia.v3.api.player.VideoAdPlayer.VideoAdPlayerCallback
*/
public Builder setVideoAdPlayerCallback(
VideoAdPlayer.VideoAdPlayerCallback videoAdPlayerCallback) {
this.videoAdPlayerCallback = checkNotNull(videoAdPlayerCallback);
return this;
}

/**
* Sets the ad UI elements to be rendered by the IMA SDK.
*
Expand Down Expand Up @@ -524,6 +541,9 @@ private ImaAdsLoader(Builder builder, @Nullable Uri adTagUri, @Nullable String a
handler = Util.createHandler(getImaLooper(), /* callback= */ null);
componentListener = new ComponentListener();
adCallbacks = new ArrayList<>(/* initialCapacity= */ 1);
if (builder.videoAdPlayerCallback != null) {
adCallbacks.add(builder.videoAdPlayerCallback);
}
updateAdProgressRunnable = this::updateAdProgress;
adInfoByAdMediaInfo = HashBiMap.create();
supportedMimeTypes = Collections.emptyList();
Expand Down

0 comments on commit 41192ee

Please sign in to comment.