Add ad event listeners in the Looper event of the ad manager callback
#minor-release PiperOrigin-RevId: 509189206 (cherry picked from commit 51929625cfeff17af413c1a06c87e10e72f218d1)
This commit is contained in:
parent
3696076f0f
commit
f2753e2e27
@ -103,6 +103,8 @@ This release corresponds to the
|
||||
* Add a method `focusSkipButton()` to the
|
||||
`ImaServerSideAdInsertionMediaSource.AdsLoader` to programmatically
|
||||
request to focus the skip button.
|
||||
* Fix a bug which prevented playback from starting for a DAI stream
|
||||
without any ads.
|
||||
* Bump IMA SDK version to 3.29.0.
|
||||
* Demo app:
|
||||
* Request notification permission for download notifications at runtime
|
||||
|
@ -554,11 +554,10 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
||||
StreamManagerLoadable streamManagerLoadable =
|
||||
new StreamManagerLoadable(
|
||||
sdkAdsLoader,
|
||||
adsLoader.configuration,
|
||||
/* imaServerSideAdInsertionMediaSource= */ this,
|
||||
streamRequest,
|
||||
streamPlayer,
|
||||
applicationAdErrorListener,
|
||||
loadVideoTimeoutMs);
|
||||
applicationAdErrorListener);
|
||||
loader.startLoading(
|
||||
streamManagerLoadable,
|
||||
new StreamManagerLoadableCallback(),
|
||||
@ -633,7 +632,6 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
||||
}
|
||||
this.streamManager.removeAdEventListener(componentListener);
|
||||
this.streamManager.destroy();
|
||||
this.streamManager = null;
|
||||
}
|
||||
this.streamManager = streamManager;
|
||||
if (streamManager != null) {
|
||||
@ -644,6 +642,12 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
||||
if (applicationAdErrorListener != null) {
|
||||
streamManager.addAdErrorListener(applicationAdErrorListener);
|
||||
}
|
||||
AdsRenderingSettings adsRenderingSettings =
|
||||
ImaSdkFactory.getInstance().createAdsRenderingSettings();
|
||||
adsRenderingSettings.setLoadVideoTimeout(loadVideoTimeoutMs);
|
||||
adsRenderingSettings.setFocusSkipButtonWhenAvailable(
|
||||
adsLoader.configuration.focusSkipButtonWhenAvailable);
|
||||
streamManager.init(adsRenderingSettings);
|
||||
}
|
||||
}
|
||||
|
||||
@ -952,7 +956,6 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
||||
@Override
|
||||
public void onLoadCompleted(
|
||||
StreamManagerLoadable loadable, long elapsedRealtimeMs, long loadDurationMs) {
|
||||
mainHandler.post(() -> setStreamManager(checkNotNull(loadable.getStreamManager())));
|
||||
setContentUri(checkNotNull(loadable.getContentUri()));
|
||||
}
|
||||
|
||||
@ -983,14 +986,12 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
||||
implements Loadable, AdsLoadedListener, AdErrorListener {
|
||||
|
||||
private final com.google.ads.interactivemedia.v3.api.AdsLoader adsLoader;
|
||||
private final ServerSideAdInsertionConfiguration serverSideAdInsertionConfiguration;
|
||||
private final ImaServerSideAdInsertionMediaSource imaServerSideAdInsertionMediaSource;
|
||||
private final StreamRequest request;
|
||||
private final StreamPlayer streamPlayer;
|
||||
@Nullable private final AdErrorListener adErrorListener;
|
||||
private final int loadVideoTimeoutMs;
|
||||
private final ConditionVariable conditionVariable;
|
||||
|
||||
@Nullable private volatile StreamManager streamManager;
|
||||
@Nullable private volatile Uri contentUri;
|
||||
private volatile boolean cancelled;
|
||||
private volatile boolean error;
|
||||
@ -1000,17 +1001,15 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
||||
/** Creates an instance. */
|
||||
private StreamManagerLoadable(
|
||||
com.google.ads.interactivemedia.v3.api.AdsLoader adsLoader,
|
||||
ServerSideAdInsertionConfiguration serverSideAdInsertionConfiguration,
|
||||
ImaServerSideAdInsertionMediaSource imaServerSideAdInsertionMediaSource,
|
||||
StreamRequest request,
|
||||
StreamPlayer streamPlayer,
|
||||
@Nullable AdErrorListener adErrorListener,
|
||||
int loadVideoTimeoutMs) {
|
||||
@Nullable AdErrorListener adErrorListener) {
|
||||
this.adsLoader = adsLoader;
|
||||
this.serverSideAdInsertionConfiguration = serverSideAdInsertionConfiguration;
|
||||
this.imaServerSideAdInsertionMediaSource = imaServerSideAdInsertionMediaSource;
|
||||
this.request = request;
|
||||
this.streamPlayer = streamPlayer;
|
||||
this.adErrorListener = adErrorListener;
|
||||
this.loadVideoTimeoutMs = loadVideoTimeoutMs;
|
||||
conditionVariable = new ConditionVariable();
|
||||
errorCode = -1;
|
||||
}
|
||||
@ -1021,12 +1020,6 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
||||
return contentUri;
|
||||
}
|
||||
|
||||
/** Returns the stream manager or null if not yet loaded. */
|
||||
@Nullable
|
||||
public StreamManager getStreamManager() {
|
||||
return streamManager;
|
||||
}
|
||||
|
||||
// Implement Loadable.
|
||||
|
||||
@Override
|
||||
@ -1080,14 +1073,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
||||
conditionVariable.open();
|
||||
return;
|
||||
}
|
||||
AdsRenderingSettings adsRenderingSettings =
|
||||
ImaSdkFactory.getInstance().createAdsRenderingSettings();
|
||||
adsRenderingSettings.setLoadVideoTimeout(loadVideoTimeoutMs);
|
||||
adsRenderingSettings.setFocusSkipButtonWhenAvailable(
|
||||
serverSideAdInsertionConfiguration.focusSkipButtonWhenAvailable);
|
||||
// After initialization completed the streamUri will be reported to the streamPlayer.
|
||||
streamManager.init(adsRenderingSettings);
|
||||
this.streamManager = streamManager;
|
||||
imaServerSideAdInsertionMediaSource.setStreamManager(streamManager);
|
||||
}
|
||||
|
||||
// AdErrorEvent.AdErrorListener implementation.
|
||||
|
Loading…
x
Reference in New Issue
Block a user