/** Builder for {@link ImaAdsLoader}. */ public static final class Builder { private final Context context; private @Nullable ImaSdkSettings imaSdkSettings; private @Nullable AdEventListener adEventListener; private @Nullable Set<UiElement> adUiElements; private int vastLoadTimeoutMs; private int mediaLoadTimeoutMs; private int mediaBitrate; private boolean focusSkipButtonWhenAvailable; private ImaFactory imaFactory; /** * Creates a new builder for {@link ImaAdsLoader}. * * @param context The context; */ public Builder(Context context) { this.context = Assertions.checkNotNull(context); vastLoadTimeoutMs = TIMEOUT_UNSET; mediaLoadTimeoutMs = TIMEOUT_UNSET; mediaBitrate = BITRATE_UNSET; focusSkipButtonWhenAvailable = true; imaFactory = new DefaultImaFactory(); } /** * Sets the IMA SDK settings. The provided settings instance's player type and version fields
@Override public void processEvent(Event event) { // Create a container object for the ads to be presented. AdDisplayContainer container = sdkFactory.createAdDisplayContainer(); container.setPlayer(googleIMAComponent.getVideoAdPlayer()); container.setAdContainer(brightcoveVideoView); // Build an ads request object and point it to the ad // display container created above. AdsRequest adsRequest = sdkFactory.createAdsRequest(); adsRequest.setAdTagUrl(adRulesURL); adsRequest.setAdDisplayContainer(container); ArrayList<AdsRequest> adsRequests = new ArrayList<AdsRequest>(1); adsRequests.add(adsRequest); // Respond to the event with the new ad requests. event.properties.put(GoogleIMAComponent.ADS_REQUESTS, adsRequests); eventEmitter.respond(event); } });
@Override public void processEvent(Event event) { // Create a container object for the ads to be presented. AdDisplayContainer container = sdkFactory.createAdDisplayContainer(); container.setPlayer(googleIMAComponent.getVideoAdPlayer()); container.setAdContainer(brightcoveVideoView); // Build an ads request object and point it to the ad // display container created above. AdsRequest adsRequest = sdkFactory.createAdsRequest(); adsRequest.setAdTagUrl(adRulesURL); adsRequest.setAdDisplayContainer(container); ArrayList<AdsRequest> adsRequests = new ArrayList<AdsRequest>(1); adsRequests.add(adsRequest); // Respond to the event with the new ad requests. event.properties.put(GoogleIMAComponent.ADS_REQUESTS, adsRequests); eventEmitter.respond(event); } });
/** * Requests video ads from the given VAST ad tag. * * @param adRequestUrl URL of the ad's VAST XML. */ public void requestAds(@NonNull String adRequestUrl, @NonNull AdControllerCallback adControllerCallback) { mAdControllerCallback = adControllerCallback; mAdDisplayContainer = mSdkFactory.createAdDisplayContainer(); mAdDisplayContainer.setPlayer(new VideoAdPlayerImpl()); mAdDisplayContainer.setAdContainer(mStubViewGroup); // Create the ads request. AdsRequest request = mSdkFactory.createAdsRequest(); request.setAdTagUrl(adRequestUrl); request.setAdDisplayContainer(mAdDisplayContainer); // Request the ad. After the ad is loaded, onAdsManagerLoaded() will be called. mAdsLoader.requestAds(request); }