Commit 4b9530c2 by andrewlewis Committed by Oliver Woodman

Let apps specify whether to focus skip button on ATV

Issue: #5019

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=219267048
parent 053a7bc0
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
* IMA extension: * IMA extension:
* For preroll to live stream transitions, project forward the loading position * For preroll to live stream transitions, project forward the loading position
to avoid being behind the live window. to avoid being behind the live window.
* Let apps specify whether to focus the skip button on ATV
([#5019](https://github.com/google/ExoPlayer/issues/5019)).
* Support for playing spherical videos on Daydream. * Support for playing spherical videos on Daydream.
* Fix issue where a `NullPointerException` is thrown when removing an unprepared * Fix issue where a `NullPointerException` is thrown when removing an unprepared
media source from a `ConcatenatingMediaSource` with the `useLazyPreparation` media source from a `ConcatenatingMediaSource` with the `useLazyPreparation`
......
...@@ -93,6 +93,7 @@ public final class ImaAdsLoader ...@@ -93,6 +93,7 @@ public final class ImaAdsLoader
private @Nullable AdEventListener adEventListener; private @Nullable AdEventListener adEventListener;
private int vastLoadTimeoutMs; private int vastLoadTimeoutMs;
private int mediaLoadTimeoutMs; private int mediaLoadTimeoutMs;
private boolean focusSkipButtonWhenAvailable;
private ImaFactory imaFactory; private ImaFactory imaFactory;
/** /**
...@@ -104,6 +105,7 @@ public final class ImaAdsLoader ...@@ -104,6 +105,7 @@ public final class ImaAdsLoader
this.context = Assertions.checkNotNull(context); this.context = Assertions.checkNotNull(context);
vastLoadTimeoutMs = TIMEOUT_UNSET; vastLoadTimeoutMs = TIMEOUT_UNSET;
mediaLoadTimeoutMs = TIMEOUT_UNSET; mediaLoadTimeoutMs = TIMEOUT_UNSET;
focusSkipButtonWhenAvailable = true;
imaFactory = new DefaultImaFactory(); imaFactory = new DefaultImaFactory();
} }
...@@ -159,6 +161,20 @@ public final class ImaAdsLoader ...@@ -159,6 +161,20 @@ public final class ImaAdsLoader
return this; return this;
} }
/**
* Sets whether to focus the skip button (when available) on Android TV devices. The default
* setting is {@code true}.
*
* @param focusSkipButtonWhenAvailable Whether to focus the skip button (when available) on
* Android TV devices.
* @return This builder, for convenience.
* @see AdsRenderingSettings#setFocusSkipButtonWhenAvailable(boolean)
*/
public Builder setFocusSkipButtonWhenAvailable(boolean focusSkipButtonWhenAvailable) {
this.focusSkipButtonWhenAvailable = focusSkipButtonWhenAvailable;
return this;
}
// @VisibleForTesting // @VisibleForTesting
/* package */ Builder setImaFactory(ImaFactory imaFactory) { /* package */ Builder setImaFactory(ImaFactory imaFactory) {
this.imaFactory = Assertions.checkNotNull(imaFactory); this.imaFactory = Assertions.checkNotNull(imaFactory);
...@@ -181,6 +197,7 @@ public final class ImaAdsLoader ...@@ -181,6 +197,7 @@ public final class ImaAdsLoader
null, null,
vastLoadTimeoutMs, vastLoadTimeoutMs,
mediaLoadTimeoutMs, mediaLoadTimeoutMs,
focusSkipButtonWhenAvailable,
adEventListener, adEventListener,
imaFactory); imaFactory);
} }
...@@ -200,6 +217,7 @@ public final class ImaAdsLoader ...@@ -200,6 +217,7 @@ public final class ImaAdsLoader
adsResponse, adsResponse,
vastLoadTimeoutMs, vastLoadTimeoutMs,
mediaLoadTimeoutMs, mediaLoadTimeoutMs,
focusSkipButtonWhenAvailable,
adEventListener, adEventListener,
imaFactory); imaFactory);
} }
...@@ -252,6 +270,7 @@ public final class ImaAdsLoader ...@@ -252,6 +270,7 @@ public final class ImaAdsLoader
private final @Nullable String adsResponse; private final @Nullable String adsResponse;
private final int vastLoadTimeoutMs; private final int vastLoadTimeoutMs;
private final int mediaLoadTimeoutMs; private final int mediaLoadTimeoutMs;
private final boolean focusSkipButtonWhenAvailable;
private final @Nullable AdEventListener adEventListener; private final @Nullable AdEventListener adEventListener;
private final ImaFactory imaFactory; private final ImaFactory imaFactory;
private final Timeline.Period period; private final Timeline.Period period;
...@@ -338,6 +357,7 @@ public final class ImaAdsLoader ...@@ -338,6 +357,7 @@ public final class ImaAdsLoader
/* adsResponse= */ null, /* adsResponse= */ null,
/* vastLoadTimeoutMs= */ TIMEOUT_UNSET, /* vastLoadTimeoutMs= */ TIMEOUT_UNSET,
/* mediaLoadTimeoutMs= */ TIMEOUT_UNSET, /* mediaLoadTimeoutMs= */ TIMEOUT_UNSET,
/* focusSkipButtonWhenAvailable= */ true,
/* adEventListener= */ null, /* adEventListener= */ null,
/* imaFactory= */ new DefaultImaFactory()); /* imaFactory= */ new DefaultImaFactory());
} }
...@@ -362,6 +382,7 @@ public final class ImaAdsLoader ...@@ -362,6 +382,7 @@ public final class ImaAdsLoader
/* adsResponse= */ null, /* adsResponse= */ null,
/* vastLoadTimeoutMs= */ TIMEOUT_UNSET, /* vastLoadTimeoutMs= */ TIMEOUT_UNSET,
/* mediaLoadTimeoutMs= */ TIMEOUT_UNSET, /* mediaLoadTimeoutMs= */ TIMEOUT_UNSET,
/* focusSkipButtonWhenAvailable= */ true,
/* adEventListener= */ null, /* adEventListener= */ null,
/* imaFactory= */ new DefaultImaFactory()); /* imaFactory= */ new DefaultImaFactory());
} }
...@@ -373,6 +394,7 @@ public final class ImaAdsLoader ...@@ -373,6 +394,7 @@ public final class ImaAdsLoader
@Nullable String adsResponse, @Nullable String adsResponse,
int vastLoadTimeoutMs, int vastLoadTimeoutMs,
int mediaLoadTimeoutMs, int mediaLoadTimeoutMs,
boolean focusSkipButtonWhenAvailable,
@Nullable AdEventListener adEventListener, @Nullable AdEventListener adEventListener,
ImaFactory imaFactory) { ImaFactory imaFactory) {
Assertions.checkArgument(adTagUri != null || adsResponse != null); Assertions.checkArgument(adTagUri != null || adsResponse != null);
...@@ -380,6 +402,7 @@ public final class ImaAdsLoader ...@@ -380,6 +402,7 @@ public final class ImaAdsLoader
this.adsResponse = adsResponse; this.adsResponse = adsResponse;
this.vastLoadTimeoutMs = vastLoadTimeoutMs; this.vastLoadTimeoutMs = vastLoadTimeoutMs;
this.mediaLoadTimeoutMs = mediaLoadTimeoutMs; this.mediaLoadTimeoutMs = mediaLoadTimeoutMs;
this.focusSkipButtonWhenAvailable = focusSkipButtonWhenAvailable;
this.adEventListener = adEventListener; this.adEventListener = adEventListener;
this.imaFactory = imaFactory; this.imaFactory = imaFactory;
if (imaSdkSettings == null) { if (imaSdkSettings == null) {
...@@ -926,6 +949,7 @@ public final class ImaAdsLoader ...@@ -926,6 +949,7 @@ public final class ImaAdsLoader
if (mediaLoadTimeoutMs != TIMEOUT_UNSET) { if (mediaLoadTimeoutMs != TIMEOUT_UNSET) {
adsRenderingSettings.setLoadVideoTimeout(mediaLoadTimeoutMs); adsRenderingSettings.setLoadVideoTimeout(mediaLoadTimeoutMs);
} }
adsRenderingSettings.setFocusSkipButtonWhenAvailable(focusSkipButtonWhenAvailable);
// Set up the ad playback state, skipping ads based on the start position as required. // Set up the ad playback state, skipping ads based on the start position as required.
long[] adGroupTimesUs = getAdGroupTimesUs(adsManager.getAdCuePoints()); long[] adGroupTimesUs = getAdGroupTimesUs(adsManager.getAdCuePoints());
......
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