ImaSdkFactory

public class ImaSdkFactory


Factory class for creating SDK objects.

Summary

Public fields

static @Nullable ImaSdkFactory

Public methods

AdDisplayContainer

This method is deprecated.

Use createAdDisplayContainer(ViewGroup container, VideoAdPlayer player) instead.

static AdDisplayContainer

Creates an AdDisplayContainer to hold the player for video ads, a container for non-linear ads, and slots for companion ads.

AdsLoader
createAdsLoader(
    Context context,
    ImaSdkSettings settings,
    AdDisplayContainer container
)

Creates an AdsLoader for requesting ads using the specified settings object.

AdsLoader
createAdsLoader(
    Context context,
    ImaSdkSettings settings,
    StreamDisplayContainer container
)

Creates an AdsLoader for requesting server-side ad insertion ads using the specified settings object.

AdsRenderingSettings

Creates an AdsRenderingSettings object to give the AdsManager parameters that control the rendering of ads.

AdsRequest

Creates an AdsRequest object to contain the data used to request ads.

AdDisplayContainer

This method is deprecated.

Use createAudioAdDisplayContainer(ViewGroup container, VideoAdPlayer player) instead.

static AdDisplayContainer

Creates an AdDisplayContainer for audio ads.

CompanionAdSlot

Creates a CompanionAdSlot for the SDK to fill with companion ads.

FriendlyObstruction
createFriendlyObstruction(
    View view,
    FriendlyObstructionPurpose purpose,
    @Nullable String detailedReason
)

Creates a FriendlyObstruction object to describe an obstruction considered "friendly" for viewability measurement purposes.

ImaSdkSettings

Creates an ImaSdkSettings object for configuring the IMA SDK.

StreamRequest

This method is deprecated.

Use createLiveStreamRequest(String assetKey, String apiKey, String networkCode) instead.

StreamRequest
createLiveStreamRequest(
    String assetKey,
    @Nullable String apiKey,
    @Nullable String networkCode
)

Creates a StreamRequest object to contain the data used to request a server-side ad insertion live stream.

StreamRequest
createPodStreamRequest(
    String networkCode,
    String customAssetKey,
    @Nullable String apiKey
)

Creates a StreamRequest object to contain the data used to request a server-side ad insertion pod serving live stream.

StreamRequest

Creates a StreamRequest object to contain the data used to request a 3rd party stitched server-side ad insertion pod serving vod stream.

StreamDisplayContainer

This method is deprecated.

Use createStreamDisplayContainer(ViewGroup container, VideoStreamPlayer player) instead.

static StreamDisplayContainer
createStreamDisplayContainer(
    ViewGroup container,
    VideoStreamPlayer player
)

Creates a StreamDisplayContainer to hold the player for server-side ad insertion streams and slots for companion ads.

StreamRequest
createVideoStitcherLiveStreamRequest(
    String networkCode,
    String customAssetKey,
    String liveStreamEventId,
    String region,
    String projectNumber,
    String oAuthToken
)

Creates a StreamRequest object to contain the data used to request a cloud video stitcher server-side ad insertion pod live serving stream.

StreamRequest
createVideoStitcherVodStreamRequest(
    String networkCode,
    String region,
    String projectNumber,
    String oAuthToken,
    String vodConfigId
)

Creates a StreamRequest object to contain the data used to request a cloud video stitcher server-side ad insertion pod serving vod stream, with a vod config flow.

StreamRequest
createVideoStitcherVodStreamRequest(
    String contentSourceUrl,
    String networkCode,
    String region,
    String projectNumber,
    String oAuthToken,
    String adTagUrl
)

Creates a StreamRequest object to contain the data used to request a cloud video stitcher server-side ad insertion pod serving vod stream.

StreamRequest
createVodStreamRequest(
    String contentSourceId,
    String videoId,
    @Nullable String apiKey
)

This method is deprecated.

Use createVodStreamRequest(String contentSourceId, String videoId, String apiKey, String networkCode) instead.

StreamRequest
createVodStreamRequest(
    String contentSourceId,
    String videoId,
    @Nullable String apiKey,
    @Nullable String networkCode
)

Creates a StreamRequest object to contain the data used to request a server-side ad insertion video on demand stream.

static ImaSdkFactory

Returns the global ImaSdkFactory object.

void
initialize(Context context, ImaSdkSettings settings)

Starts to preload SDK resources in advance.

Public fields

instance

public static @Nullable ImaSdkFactory instance

Public methods

createAdDisplayContainer

public AdDisplayContainer createAdDisplayContainer()

Creates an AdDisplayContainer to hold the player for video ads, a container for non-linear ads, and slots for companion ads.

createAdDisplayContainer

public static AdDisplayContainer createAdDisplayContainer(ViewGroup container, VideoAdPlayer player)

Creates an AdDisplayContainer to hold the player for video ads, a container for non-linear ads, and slots for companion ads.

createAdsLoader

public AdsLoader createAdsLoader(
    Context context,
    ImaSdkSettings settings,
    AdDisplayContainer container
)

Creates an AdsLoader for requesting ads using the specified settings object. This is the only way to specify a non-default language for the Ad UI.

Parameters
Context context

Context for the an upcoming ad request. Required to use the activity context.

ImaSdkSettings settings

The settings for the SDK in an upcoming ad request. This parameter requires an ImaSdkSettings object.

AdDisplayContainer container

The container for IMA to render the ad UI.

createAdsLoader

public AdsLoader createAdsLoader(
    Context context,
    ImaSdkSettings settings,
    StreamDisplayContainer container
)

Creates an AdsLoader for requesting server-side ad insertion ads using the specified settings object. This is the only way to specify a non-default language for the Ad UI.

Parameters
Context context

Context for the an upcoming stream request. Required to use the activity context.

ImaSdkSettings settings

The settings for the SDK in an upcoming stream request. This parameter requires an ImaSdkSettings object.

StreamDisplayContainer container

The container for IMA to render the ad UI.

createAdsRenderingSettings

public AdsRenderingSettings createAdsRenderingSettings()

Creates an AdsRenderingSettings object to give the AdsManager parameters that control the rendering of ads.

createAdsRequest

public AdsRequest createAdsRequest()

Creates an AdsRequest object to contain the data used to request ads.

createAudioAdDisplayContainer

public AdDisplayContainer createAudioAdDisplayContainer(Context context)

Creates an AdDisplayContainer for audio ads. In order to properly handle companion ads this should be created in the same process as your main Activity.

createAudioAdDisplayContainer

public static AdDisplayContainer createAudioAdDisplayContainer(Context context, VideoAdPlayer player)

Creates an AdDisplayContainer for audio ads. In order to properly handle companion ads this should be created in the same process as your main Activity.

createCompanionAdSlot

public CompanionAdSlot createCompanionAdSlot()

Creates a CompanionAdSlot for the SDK to fill with companion ads.

createFriendlyObstruction

public FriendlyObstruction createFriendlyObstruction(
    View view,
    FriendlyObstructionPurpose purpose,
    @Nullable String detailedReason
)

Creates a FriendlyObstruction object to describe an obstruction considered "friendly" for viewability measurement purposes. If the detailedReason is not null, it must follow the IAB standard by being 50 characters or less and only containing characters A-z , 0-9, or spaces.

createImaSdkSettings

public ImaSdkSettings createImaSdkSettings()

Creates an ImaSdkSettings object for configuring the IMA SDK.

createLiveStreamRequest

public StreamRequest createLiveStreamRequest(String assetKey, @Nullable String apiKey)

Creates a StreamRequest object to contain the data used to request a server-side ad insertion live stream.

Parameters
String assetKey

Determines which stream you request. The live stream request asset key is an identifier that you can find in the Ad Manager UI. For more information, see Locate live linear stream URL and asset key.

createLiveStreamRequest

public StreamRequest createLiveStreamRequest(
    String assetKey,
    @Nullable String apiKey,
    @Nullable String networkCode
)

Creates a StreamRequest object to contain the data used to request a server-side ad insertion live stream.

Parameters
String assetKey

Determines which stream you request. The live stream request asset key is an identifier which you can find in the Ad Manager UI.

@Nullable String apiKey

Optional: The stream request API key. Set up the key in the Ad Manager Admin UI and use it in the application to unlock the content. The key verifies applications to access the content.

@Nullable String networkCode

Optional: The network code for the Ad Manager account that owns the stream. The code is recommended because it is used to apply settings selected in the Ad Manager UI such as programmatic limited ads enablement. To find the network code, see Find Ad Manager account information .

createPodStreamRequest

public StreamRequest createPodStreamRequest(
    String networkCode,
    String customAssetKey,
    @Nullable String apiKey
)

Creates a StreamRequest object to contain the data used to request a server-side ad insertion pod serving live stream.

Parameters
String networkCode

The network code for the publisher making this stream request. Network codes are required for pod serving stream requests; with an invalid code the stream request will fail. The code is also used to apply settings selected in the Ad Manager UI such as programmatic limited ads enablement. To find the network code, see this article.

String customAssetKey

The custom asset key is used to determine which stream should be played. Custom asset keys are required for pod serving stream requests.

@Nullable String apiKey

Optional: The stream request API key. Set up the key in the Ad Manager Admin UI and use it in the application to unlock the content. The key verifies applications to access the content.

createPodVodStreamRequest

public StreamRequest createPodVodStreamRequest(String networkCode)

Creates a StreamRequest object to contain the data used to request a 3rd party stitched server-side ad insertion pod serving vod stream.

createStreamDisplayContainer

public StreamDisplayContainer createStreamDisplayContainer()

Creates a StreamDisplayContainer to hold the player for server-side ad insertion streams and slots for companion ads.

createStreamDisplayContainer

public static StreamDisplayContainer createStreamDisplayContainer(
    ViewGroup container,
    VideoStreamPlayer player
)

Creates a StreamDisplayContainer to hold the player for server-side ad insertion streams and slots for companion ads.

createVideoStitcherLiveStreamRequest

public StreamRequest createVideoStitcherLiveStreamRequest(
    String networkCode,
    String customAssetKey,
    String liveStreamEventId,
    String region,
    String projectNumber,
    String oAuthToken
)

Creates a StreamRequest object to contain the data used to request a cloud video stitcher server-side ad insertion pod live serving stream.

createVideoStitcherVodStreamRequest

public StreamRequest createVideoStitcherVodStreamRequest(
    String networkCode,
    String region,
    String projectNumber,
    String oAuthToken,
    String vodConfigId
)

Creates a StreamRequest object to contain the data used to request a cloud video stitcher server-side ad insertion pod serving vod stream, with a vod config flow.

createVideoStitcherVodStreamRequest

public StreamRequest createVideoStitcherVodStreamRequest(
    String contentSourceUrl,
    String networkCode,
    String region,
    String projectNumber,
    String oAuthToken,
    String adTagUrl
)

Creates a StreamRequest object to contain the data used to request a cloud video stitcher server-side ad insertion pod serving vod stream.

createVodStreamRequest

public StreamRequest createVodStreamRequest(
    String contentSourceId,
    String videoId,
    @Nullable String apiKey
)

Creates a StreamRequest object to contain the data used to request a server-side ad insertion video on demand stream.

createVodStreamRequest

public StreamRequest createVodStreamRequest(
    String contentSourceId,
    String videoId,
    @Nullable String apiKey,
    @Nullable String networkCode
)

Creates a StreamRequest object to contain the data used to request a server-side ad insertion video on demand stream.

Parameters
String contentSourceId

The content source ID for video on demand server-side ad insertion streams.

String videoId

The video ID for video on demand server-side ad insertion streams.

@Nullable String apiKey

Optional: The stream request API key. Set up the key in the Ad Manager Admin UI and use it in the application to unlock the content. The key verifies applications to access the content.

@Nullable String networkCode

Optional: The network code for the Ad Manager account that owns the stream. The code is recommended because it is used to apply settings selected in the Ad Manager UI such as programmatic limited ads enablement. To find the network code, see Find Ad Manager account information.

getInstance

public static ImaSdkFactory getInstance()

Returns the global ImaSdkFactory object.

initialize

public void initialize(Context context, ImaSdkSettings settings)

Starts to preload SDK resources in advance. Initialization only needs to be called once before the first adsloader is created. Initialization is optional but recommended, as it prepares components for each adsloader, improving the first ad/stream request response time.

Parameters
Context context

Context for the SDK. Recommend to use the application context.

ImaSdkSettings settings

The settings for the SDK in an upcoming ad request. This parameter requires an ImaSdkSettings object.