/** * Fired when an event occurs. * * @category Events * @public */ interface Event { /** * The type of the event. */ type: TType; /** * The creation date of the event. */ date: Date; } /** * The function to be executed when an event occurred. * * @category Events * @public */ type EventListener = (event: TEvent) => void; /** * A record used to map events. * Each entry contains an event name with associated event interface. * * @example * ``` * { * 'statechange': StateChangeEvent, * 'error': ErrorEvent * } * ``` * * @category Events * @public */ type EventMap = { [type in TType]: Event; }; /** * Helper type to extract string keys from type objects. * * @public */ type StringKeyOf = Extract; /** * Dispatches events that are fired. * * @category Events * @public */ interface EventDispatcher>> { /** * Add the given listener for the given event type(s). * * @param type - The type of the event. * @param listener - The callback which is executed when the event occurs. */ addEventListener>(type: TType | readonly TType[], listener: EventListener): void; /** * Remove the given listener for the given event type(s). * * @param type - The type of the event. * @param listener - The callback which will be removed. */ removeEventListener>(type: TType | readonly TType[], listener: EventListener): void; } /** * Fired when the ad has stalled playback to buffer. * * @category Ads * @category Events * @public */ interface AdBufferingEvent extends AdEvent<'adbuffering'> { /** * The ad which is buffered. */ readonly ad: GoogleImaAd; } /** * Fired when an ads list is loaded. * * @category Ads * @category Events * @public */ interface AdMetadataEvent extends Event<'admetadata'> { } /** * The Google DAI API. * * @remarks *
- Available since v3.7.0. * * @category Ads * @public */ interface GoogleDAI { /** * Returns the content time without ads for a given stream time. Returns the given stream time for live streams. * * @param time - The stream time with inserted ads (in seconds). */ contentTimeForStreamTime(time: number): number; /** * Returns the stream time with ads for a given content time. Returns the given content time for live streams. * * @param time - The content time without any ads (in seconds). */ streamTimeForContentTime(time: number): number; /** * Replaces all the ad tag parameters used for upcoming ad requests for a live stream. * * @param adTagParameters - The new ad tag parameters. */ replaceAdTagParameters(adTagParameters?: Record): void; /** * Whether snapback is enabled. When enabled and the user seeks over multiple ad breaks, the last ad break that was seeked past will be played. */ snapback: boolean; /** * A source transformer which will receive the source as returned from Google DAI before loading it in the player. This capability can be useful * if you need to add authentication tokens or signatures to the source URL as returned by Google. */ sourceTransformer: (url: string) => string | Promise; } /** * A synchronous or asynchronous return type * * @public */ type MaybeAsync = T | PromiseLike; /** * A code that indicates the type of error that has occurred. * * @category Errors * @public */ declare enum ErrorCode { /** * The configuration provided is invalid. */ CONFIGURATION_ERROR = 1000, /** * The license provided is invalid. */ LICENSE_ERROR = 2000, /** * The provided license does not contain the current domain. */ LICENSE_INVALID_DOMAIN = 2001, /** * The current source is not allowed in the license provided. */ LICENSE_INVALID_SOURCE = 2002, /** * The license has expired. */ LICENSE_EXPIRED = 2003, /** * The provided license does not contain the necessary feature. */ LICENSE_INVALID_FEATURE = 2004, /** * The source provided is not valid. */ SOURCE_INVALID = 3000, /** * The provided source is not supported. */ SOURCE_NOT_SUPPORTED = 3001, /** * The manifest could not be loaded. */ MANIFEST_LOAD_ERROR = 4000, /** * An Error related to Cross-origin resource sharing (CORS). * * @remarks *
- See {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS | Cross-Origin Resource Sharing (CORS)}. */ MANIFEST_CORS_ERROR = 4001, /** * The manifest could not be parsed. */ MANIFEST_PARSE_ERROR = 4002, /** * The media is not supported. */ MEDIA_NOT_SUPPORTED = 5000, /** * The media could not be loaded. */ MEDIA_LOAD_ERROR = 5001, /** * The media could not be decoded. */ MEDIA_DECODE_ERROR = 5002, /** * An error related to playback through AVPlayer in the iOS or tvOS SDK. */ MEDIA_AVPLAYER_ERROR = 5003, /** * The fetching process for the media resource was aborted by the user agent at the user's request. */ MEDIA_ABORTED = 5004, /** * Something went wrong in the internal logic of the media pipeline. */ MEDIA_INTERNAL_ERROR = 5005, /** * An error related to network has been detected. */ NETWORK_ERROR = 6000, /** * The network has timed out. */ NETWORK_TIMEOUT = 6001, /** * An error related to the content protection. */ CONTENT_PROTECTION_ERROR = 7000, /** * The DRM provided is not supported on this platform. */ CONTENT_PROTECTION_NOT_SUPPORTED = 7001, /** * The media is DRM protected, but no content protection configuration was provided. */ CONTENT_PROTECTION_CONFIGURATION_MISSING = 7002, /** * The content protection configuration is invalid. */ CONTENT_PROTECTION_CONFIGURATION_INVALID = 7003, /** * The DRM initialization data could not be parsed. */ CONTENT_PROTECTION_INITIALIZATION_INVALID = 7004, /** * The content protection's certificate could not be loaded. */ CONTENT_PROTECTION_CERTIFICATE_ERROR = 7005, /** * The content protection's certificate is invalid. */ CONTENT_PROTECTION_CERTIFICATE_INVALID = 7006, /** * The content protection's license could not be loaded. */ CONTENT_PROTECTION_LICENSE_ERROR = 7007, /** * The content protection's license is invalid. */ CONTENT_PROTECTION_LICENSE_INVALID = 7008, /** * The content protection's key has expired. */ CONTENT_PROTECTION_KEY_EXPIRED = 7009, /** * The content protection's key is missing. */ CONTENT_PROTECTION_KEY_MISSING = 7010, /** * All qualities require HDCP, but the current output does not fulfill HDCP requirements. */ CONTENT_PROTECTION_OUTPUT_RESTRICTED = 7011, /** * Something went wrong in the internal logic of the content protection system. */ CONTENT_PROTECTION_INTERNAL_ERROR = 7012, /** * The content protection system has revoked this device, so it can no longer play protected content. */ CONTENT_PROTECTION_DEVICE_REVOKED = 7013, /** * The device could not be provisioned with the credentials it needs to play protected content. */ CONTENT_PROTECTION_PROVISIONING_ERROR = 7014, /** * Loading subtitles has failed. */ SUBTITLE_LOAD_ERROR = 8000, /** * Loading subtitles has failed due to CORS. * * @remarks *
- See {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS | Cross-Origin Resource Sharing (CORS)}. */ SUBTITLE_CORS_ERROR = 8001, /** * Parsing subtitles has failed. */ SUBTITLE_PARSE_ERROR = 8002, /** * This error occurs when VR is not supported on the current platform. */ VR_PLATFORM_UNSUPPORTED = 9000, /** * Changing the presentation to VR was not possible. */ VR_PRESENTATION_ERROR = 9001, /** * Something went wrong with an ad. */ AD_ERROR = 10000, /** * An ad blocker has been detected. */ AD_BLOCKER_DETECTED = 10001, /** * Changing the presentation to fullscreen was not possible. */ FULLSCREEN_ERROR = 11000, /** * Changing the presentation to picture-in-picture was not possible. */ PICTURE_IN_PICTURE_ERROR = 11001, /** * Something went wrong while caching a source. */ CACHE_SOURCE_ERROR = 12000, /** * Something went wrong while caching content protection's license. */ CACHE_CONTENT_PROTECTION_ERROR = 12001, /** * Something went wrong with THEOlive playback. */ THEO_LIVE_UNKNOWN_ERROR = 13000, /** * The THEOlive channel could not be played because it was not found. This can be because it was never created, it has been deleted or locked. */ THEO_LIVE_CHANNEL_NOT_FOUND = 13001, /** * The THEOlive channel is a demo channel and the demo window has expired. */ THEO_LIVE_END_OF_DEMO = 13002, /** * A fatal error occurred regarding THEOlive analytics. */ THEO_LIVE_ANALYTICS_ERROR = 13003 } /** * The category of an error. * * @category Errors * @public */ declare enum ErrorCategory { /** * This category clusters all errors related to the configuration. */ CONFIGURATION = 1, /** * This category clusters all errors related to the license. */ LICENSE = 2, /** * This category clusters all errors related to the source. */ SOURCE = 3, /** * This category clusters all errors related to the manifest. */ MANIFEST = 4, /** * This category clusters all errors related to the media. */ MEDIA = 5, /** * This category clusters all errors related to the network. */ NETWORK = 6, /** * This category clusters all errors related to the content protection. */ CONTENT_PROTECTION = 7, /** * This category clusters all errors related to the subtitles. */ SUBTITLE = 8, /** * This category clusters all errors related to VR. */ VR = 9, /** * This category clusters all errors related to ads. */ AD = 10, /** * This category clusters all errors related to fullscreen. */ FULLSCREEN = 11, /** * This category clusters all errors related to caching. */ CACHE = 12, /** * This category clusters all errors related to THEOlive. */ THEOLIVE = 13 } /** * The category of an error. * * @category Errors * @public */ declare namespace ErrorCategory { /** * Determine the `ErrorCategory` of the given {@link ErrorCode}. * * @param code - The {@link ErrorCode} to determine the `ErrorCategory` of. */ function fromCode(code: ErrorCode): ErrorCategory; } /** * A handler for a server-side ad integration. * * You can implement one or more of these methods to hook into various parts * of the player's lifecycle and perform your integration-specific ad handling. * * Use the {@link ServerSideAdIntegrationController} provided by {@link ServerSideAdIntegrationFactory} * to update the state of your integration. * * @see {@link Ads.registerServerSideIntegration} * * @category Ads */ interface ServerSideAdIntegrationHandler { /** * Handler which will be called when a new source is loaded into the player. * * This allows the integration to transform the source description, * e.g. by calling an external service to replace {@link TypedSource.src | the content URL}, * or by adding a fixed pre-roll linear ad to {@link SourceDescription.ads | the list of ads}. * * @remarks * - If this handler throws an error, the player fires a fatal {@link PlayerEventMap.error | `error`} event * (as if by calling {@link ServerSideAdIntegrationController.fatalError}). * * @param source */ setSource?(source: SourceDescription): MaybeAsync; /** * Handler which will be called when an ad is requested to be skipped. * * To skip the ad, the handler should call {@link ServerSideAdIntegrationController.skipAd}. * * @remarks * - This is only called for ads whose {@link Ad.integration} * matches {@link ServerSideAdIntegrationController.integration}. * - If this handler is missing, the player will always skip the ad * by calling {@link ServerSideAdIntegrationController.skipAd}. * - If this handler throws an error, the player fires a non-fatal {@link AdsEventMap.aderror | `aderror`} event * (as if by calling {@link ServerSideAdIntegrationController.error}). * * @param ad */ skipAd?(ad: Ad): void; /** * Handler which will be called before a new source is loaded into the player, * or before the player is destroyed. * * This allows the integration to clean up any source-specific resources, * such as scheduled ads or pending HTTP requests. * * @remarks * - If this handler is missing, the player will remove all remaining ads * by calling {@link ServerSideAdIntegrationController.removeAllAds}. * - If this handler throws an error, the player fires a fatal {@link PlayerEventMap.error | `error`} event * (as if by calling {@link ServerSideAdIntegrationController.fatalError}). */ resetSource?(): MaybeAsync; /** * Handler which will be called when the player is {@link ChromelessPlayer.destroy | destroyed}. * * This allows the integration to clean up any resources, such as DOM elements or event listeners. */ destroy?(): MaybeAsync; } /** * A controller to be used by your {@link ServerSideAdIntegrationHandler} * to update the state of your custom server-side ad integration. * * @see {@link Ads.registerServerSideIntegration} * * @category Ads */ interface ServerSideAdIntegrationController { /** * The identifier for this integration, as it was passed to {@link Ads.registerServerSideIntegration}. */ readonly integration: CustomAdIntegrationKind; /** * The scheduled ads managed by this integration. * * @remarks * Use {@link ServerSideAdIntegrationController.createAd} and {@link ServerSideAdIntegrationController.removeAd} to add or remove ads. */ readonly ads: readonly Ad[]; /** * The scheduled ad breaks managed by this integration. * * @remarks * Use {@link ServerSideAdIntegrationController.createAdBreak} and {@link ServerSideAdIntegrationController.removeAdBreak} to add or remove ad breaks. */ readonly adBreaks: readonly AdBreak[]; /** * Create a new ad. * * @remarks * - The ad will be added to {@link Ads.scheduledAds}. * * @param init * The initial properties to be set on the created ad. * @param [adBreak] * If given, appends the ad to the given existing {@link AdBreak}. * Otherwise, appends the ad to a new or existing {@link AdBreak} with the configured {@link AdInit.timeOffset}. */ createAd(init: AdInit, adBreak?: AdBreak): Ad; /** * Update the given ad. * * @param ad * The ad to be updated. * @param init * The properties to be updated on the ad. */ updateAd(ad: Ad, init: Partial): void; /** * Update the playback progression of the given ad. * * @remarks * - The player will fire progression events such as {@link AdsEventMap.adfirstquartile}, * {@link AdsEventMap.admidpoint} and {@link AdsEventMap.adthirdquartile}. * * @param ad * The ad to be updated. * @param progress * The playback progress, as a number between 0 (at the start of the ad) and 1 (at the end of the ad). * @throws Error * If the ad is not {@link ServerSideAdIntegrationController.beginAd | started}. */ updateAdProgress(ad: Ad, progress: number): void; /** * Begin the given ad. * * @remarks * - The ad will be added to {@link Ads.currentAds}. * - An {@link AdsEventMap.adbegin} event will be fired. * * @param ad */ beginAd(ad: Ad): void; /** * End the given ad. * * @remarks * - The ad will be removed from {@link Ads.currentAds}. * - If the ad was currently playing, an {@link AdsEventMap.adend} event will be fired. * * @param ad */ endAd(ad: Ad): void; /** * Skip the given ad. * * @remarks * - The ad will be removed from {@link Ads.currentAds}. * - If the ad was currently playing, an {@link AdsEventMap.adskip} event will be fired. * * @param ad */ skipAd(ad: Ad): void; /** * Remove the given ad. * * @remarks * - The ad will be removed from {@link Ads.currentAds} and {@link Ads.scheduledAds}. * - If the ad was currently playing, it will first be {@link ServerSideAdIntegrationController.endAd | ended}. * * @param ad */ removeAd(ad: Ad): void; /** * Create a new ad break. * * This can be used to indicate where ad breaks can be expected in advance, * before populating those ad breaks with ads. * * @remarks * - The ad break will be added to {@link ServerSideAdIntegrationController.adBreaks} and {@link Ads.scheduledAdBreaks}. * * @param init * The initial properties to be set on the created ad break. * @throws Error * If there is already an existing ad break with the given {@link AdBreakInit.timeOffset}. */ createAdBreak(init: AdBreakInit): AdBreak; /** * Update the given ad break. * * @param adBreak * The ad break to be updated. * @param init * The properties to be updated on the ad break. */ updateAdBreak(adBreak: AdBreak, init: Partial): void; /** * Remove the given ad break and all of its ads. * * @remarks * - The ad break will be removed from {@link ServerSideAdIntegrationController.adBreaks} and {@link Ads.scheduledAdBreaks}. * - Any remaining ads in the ad break will be {@link ServerSideAdIntegrationController.removeAd | removed}. * * @param adBreak * The ad break to be removed. */ removeAdBreak(adBreak: AdBreak): void; /** * Remove all ads and ad breaks. * * @remarks * - This is a shorthand for calling {@link ServerSideAdIntegrationController.removeAdBreak} * on all ad breaks in {@link ServerSideAdIntegrationController.adBreaks}. */ removeAllAds(): void; /** * Fire an {@link AdsEventMap.aderror | `aderror`} event on the player. * * This does not stop playback. * * @param error - The error. */ error(error: Error): void; /** * Fire a fatal {@link PlayerEventMap.error | `error`} event on the player. * * This stops playback immediately. Use {@link ChromelessPlayer.source} to load a new source. * * @param error * The error. * @param [code] * The error code. By default, this is set to {@link ErrorCode.AD_ERROR}. */ fatalError(error: Error, code?: ErrorCode): void; } /** * An initializer for a custom {@link Ad}. * * @see {@link ServerSideAdIntegrationController.createAd} * @see {@link ServerSideAdIntegrationController.updateAd} * * @category Ads */ interface AdInit extends Omit, 'integration' | 'adBreak'> { /** * The type of the ad. */ type: AdType; /** * The time offset at which content will be paused to play the ad, in seconds. */ timeOffset?: number; /** * Additional integration-specific data associated with this ad. */ customData?: unknown; } /** * An initializer for a custom {@link AdBreak}. * * @see {@link ServerSideAdIntegrationController.createAdBreak} * @see {@link ServerSideAdIntegrationController.updateAdBreak} * * @category Ads */ interface AdBreakInit { /** * The identifier of the ad break. */ id?: string | undefined; /** * The time offset at which content will be paused to play the ad break, in seconds. */ timeOffset: number; /** * The duration of the ad break, in seconds. */ maxDuration?: number | undefined; /** * Additional integration-specific data associated with this ad break. */ customData?: unknown; } /** * Factory to create an {@link ServerSideAdIntegrationHandler}. * * @param controller * The controller to use. * @return The new server-side ad integration handler. * * @see {@link Ads.registerServerSideIntegration} * * @category Ads */ type ServerSideAdIntegrationFactory = (controller: ServerSideAdIntegrationController) => ServerSideAdIntegrationHandler; /** * Fired when the {@link https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/js/google.ima.AdsManager | google.ima.AdsManager} is created. * * @category Ads * @category Events * @public */ interface AdsManagerLoadedEvent extends Event<'adsmanagerloaded'> { /** * The {@link https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/js/google.ima.AdsManager | google.ima.AdsManager} */ readonly adsManager: any; } /** * Represents a VAST creative. It is either a linear or non-linear ad. * * @category Ads * @public */ interface Ad { /** * The source ad server information included in the ad response. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. */ adSystem: string | undefined; /** * The integration of the ad, represented by a value from {@link AdIntegrationKind} * or {@link CustomAdIntegrationKind | the identifier of a custom integration} added with {@link Ads.registerServerSideIntegration}. * * @defaultValue `'csai'` * * @remarks *
- The `'theo'` integration naming is deprecated and has been replaced with `'csai'`. */ integration?: AdIntegrationKind | CustomAdIntegrationKind; /** * The type of the ad. */ type: AdType; /** * The identifier of the ad. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. */ id: string | undefined; /** * The ready state of the ad. */ readyState?: AdReadyState; /** * The ad break which the ad is part of. * * @remarks *
- Available for VAST-ads. */ adBreak: AdBreak; /** * The duration of the ad, in seconds. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. *
- Only available for LinearAd. */ duration: number | undefined; /** * The width of the ad, in pixels. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. */ width: number | undefined; /** * The height of the ad. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. */ height: number | undefined; /** * The URI of the ad content. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. */ resourceURI: string | undefined; /** * The website of the advertisement. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. */ clickThrough: string | undefined; /** * List of companions which can be displayed outside the player. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. *
- Only supported for `'csai'` and `'google-dai'`. */ companions: CompanionAd[]; /** * Offset after which the ad break may be skipped, in seconds. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. *
- If the offset is -1, the ad is unskippable. *
- If the offset is 0, the ad is immediately skippable. *
- Otherwise it must be a positive number indicating the offset. */ skipOffset: number | undefined; /** * The identifier of the selected creative for the ad. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. */ creativeId: string | undefined; /** * The title of the ad. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. */ title: string | undefined; /** * The list of universal ad ID information of the selected creative for the ad. * * @remarks *
- Only supported for `'csai'` and `'google-ima'`. */ universalAdIds: UniversalAdId[]; /** * Additional integration-specific data associated with this ad. */ customData: unknown; /** * Whether the ad is a slate or not. * * @remarks *
- Only used for THEOads ads. */ isSlate: boolean; } /** * The type of the ad, represented by a value from the following list: *
- `'linear'` *
- `'nonlinear'` * * @category Ads * @public */ type AdType = 'linear' | 'nonlinear'; /** * The ad preloading strategy, represented by a value from the following list: *
- `'none'`: Ads are not preloaded. *
- `'midroll-and-postroll'`: Media files of mid- and postrolls are preloaded. * * @remarks *
- For Google IMA, preloading starts 8 seconds before ad playback. * * @category Ads * @public */ type AdPreloadType = 'none' | 'midroll-and-postroll'; /** * The ad readiness state, represented by a value from the following list: *
- `'none'`: The ad not loaded state. *
- `'ready'`: The ad loaded state. * * @remarks *
- An ad is loaded when the ad resource (e.g. VAST file) is downloaded. * * @category Ads * @public */ type AdReadyState = 'none' | 'ready'; /** * Describes the configuration of advertisement. * * @category Ads * @public */ interface AdsConfiguration { /** * Allows configuring which mime types are allowed during ad playback. * * @remarks *
- If set to an array, all ads with another mime types will be ignored. *
- If set to `undefined`: * - for Google IMA, the ad system will pick media based on the browser's capabilities. * - for the other integrations, the ad system will ignore all streaming ads. * * @defaultValue `undefined` */ allowedMimeTypes?: string[]; /** * Whether an advertisement duration countdown will be shown in the UI. * * @deprecated use {@link GoogleImaConfiguration.uiElements} instead * * @remarks *
- Available since v2.22.9. *
- This feature is only available for Google IMA. * * @defaultValue `true` */ showCountdown?: boolean; /** * Whether media files of mid- and postrolls are preloaded. * * @remarks *
- This feature is only available for Google IMA. * * @defaultValue `'midroll-and-postroll'` */ preload?: AdPreloadType; /** * The iframe policy for VPAID ads. * * @remarks *
- This feature is only available for Google IMA and SpotX. * * @defaultValue `'enabled'` */ vpaidMode?: VPAIDMode; /** * The Google IMA configuration. */ googleIma?: GoogleImaConfiguration; /** * Whether to enable THEOads support. * * @remarks *
- Available since 8.2.0. *
- This must be set to `true` in order to schedule a {@link TheoAdDescription}. * * @defaultValue `false` */ theoads?: boolean; /** * Flag to allow seeking out of ads with `skipAdBreak` when using the `csai` integration. * * @remarks *
- Available since 9.4.0. */ allowSkipAdBreak?: boolean; /** * The configuration for the THEOplayer CSAI ad integration. */ csai?: CsaiConfiguration; } /** * Describes the configuration of the THEOplayer CSAI ad integration. * * @category Ads * @public */ interface CsaiConfiguration { /** * The recommended bitrate in kbit/s for selecting ad media files. * * @remarks *
- When set to `-1`, the player picks the ad media file with the highest available bitrate * (matching the behavior of {@link GoogleImaConfiguration.bitrate}). *
- When set to a positive value, the player picks the highest-bitrate ad media file at or below the * specified maximum. If no ad has a bitrate at or below the maximum, the ad with the bitrate closest to * the maximum is picked. *
- When set to `0` (the default), no bitrate-based selection is performed; the player falls back to its * default resolution-based selection for progressive media files. *
- When bitrate-based selection is active (`-1` or positive), it overrides the default resolution-based * selection for progressive (e.g. mp4) ad media files. *
- Bitrate information is taken from the `bitrate` attribute on the VAST `` element. Media * files without this attribute are skipped during bitrate-based selection. * * @defaultValue 0 */ bitrate?: number; /** * The maximum amount of time, in milliseconds, to wait for an ad media file to start playing * after its source has been set. If the ad does not start playing within this time, an ad * error will be reported and playback will continue with the main content (or the next ad). * * @remarks *
- When set to `0`, no timeout is applied (the player will wait indefinitely). * * @defaultValue `0` */ loadVideoTimeout?: number; } /** * Describes the configuration of Google IMA. * * @category Ads * @public */ interface GoogleImaConfiguration { /** * Whether to use an ad UI element for clickthrough and displaying other ad UI. * * @remarks *
- Available since v8.6.0. *
- If set to `true`, Google DAI can show additional ad UI elements * on top of the player for certain ads, such as a skip button for skippable ads * or a specific UI for GDPR compliance. *
- If set to `false`, Google DAI ads will only show a basic "Learn More" button. * Ads that need additional UI elements will not be played. *
- This only applies to Google DAI server-side inserted ads. * Client-side ads from Google IMA can always show additional UI elements. *
- This flag is enabled by default since v10.0.0. * * @defaultValue `true` (was `false` in version 9 and lower) */ useAdUiElementForSsai?: boolean; /** * The maximum recommended bitrate in kbit/s. Ads with a bitrate below the specified maximum will be picked. * * @remarks *
- When set to -1, it will select the ad with the highest bitrate. *
- If there is no ad below the specified maximum, the ad closest to the bitrate will be picked. * * @defaultValue -1 */ bitrate?: number; /** * The language code of the UI elements. See {@link https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/localization | localization docs} for more information. * * @remarks *
- This will default to {@link UIConfiguration.language} when not specified. * */ language?: string; /** * The UI elements passed to Google IMA. See {@link https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/js/google.ima#.UiElements | Google IMA docs} for more information. * * @remarks *
- Available since v6.13.0. */ uiElements?: string[]; /** * A flag to enable seeking during an ad break in a DAI stream. * * @remarks *
- Available since v9.2.0 * * @defaultValue false */ allowSeekingForGoogleDai?: boolean; } /** * Represents a non-linear ad in the VAST specification. * * @category Ads * @public */ interface NonLinearAd extends Ad { /** * The alternative description for the ad. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. */ altText: string | undefined; /** * The website of the ad. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. */ clickThrough: string | undefined; /** * The HTML-string with the content of the ad. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. */ contentHTML: string | undefined; } /** * The delivery type of the ad content file, represented by a value from the following list: *
- `'progressive'`: Delivered through progressive download protocols (e.g. HTTP). *
- `'streaming'`: Delivered through streaming download protocols. * * @category Ads * @public */ type DeliveryType = 'progressive' | 'streaming'; /** * Represents metadata of a media file with ad content. * * @remarks *
- This metadata is retrieved from the VAST file. * * @category Ads * @public */ interface MediaFile { /** * The delivery type of the video file. */ delivery: DeliveryType; /** * The MIME type for the file container. */ type: string; /** * The native width of the video file, in pixels. */ width: number; /** * The native height of the video file, in pixels. */ height: number; /** * The bitrate of the video file, in kbit/s. * * @remarks *
- Available when the VAST `` element has a `bitrate` attribute. */ bitrate?: number; /** * The URI of the VAST content. */ contentURL: string; } /** * Represents metadata of a closed caption for a media file with ad content. * * @remarks *
- This metadata is retrieved from the VAST file. * * @category Ads * @public */ interface ClosedCaptionFile { /** * The MIME type for the file. */ type: string; /** * The language of the Closed Caption file using ISO 631-1 codes. An optional locale * suffix can also be provided. * * @example * "en", "en-US", "zh-TW" */ language: string; /** * The URI of the file providing Closed Caption info for the media file. */ contentURL: string; } /** * Represents the contents of an Extension tag found under an Inline or Wrapper's Extensions tag (if present). * * @remarks *
- Available since 9.4.0. *
- Only parsed for the `csai` integration. * * @category Ads * @public */ interface VastExtension { /** * A type to identify the Extension. */ type: string; /** * String representation of the custom xml wrapped inside the Extension tag as found in the VAST. * */ xml: string; } /** * Represents a linear ad in the VAST specification. * * @category Ads * @public */ interface LinearAd extends Ad { /** * The duration of the ad, in seconds. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. */ duration: number; /** * List of media files which contain metadata about ad video files. */ mediaFiles: MediaFile[]; /** * The URL of the media file loaded for ad playback. Returns undefined if no URL is available yet. * * @remarks *
- Available when the ad break has started. */ mediaUrl?: string; /** * List of closed caption files which contain metadata about the closed captions that accompany any media files. */ closedCaptionFiles: ClosedCaptionFile[]; /** * List of Extensions found in the related Inline or Wrapper tag * * @remarks *
- Available since 9.4.0. */ extensions: VastExtension[]; } /** * Represents a Google IMA creative compliant to the VAST specification. * * @remarks *
- Available since v2.60.0. * * @category Ads * @public */ interface GoogleImaAd extends Ad { /** * The bitrate of the currently playing creative as listed in the VAST response or 0. */ readonly bitrate: number; /** * Record of custom parameters for the ad at the time of ad trafficking. * Each entry contains a parameter name with associated value. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. *
- Only available for the `google-ima` integration. */ traffickingParameters: { [parameterKey: string]: string; } | undefined; /** * Return title of the advertisement. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. */ title: string | undefined; /** * The custom parameters for the ad at the time of ad trafficking, as a string. * * @remarks *
- Available for `google-ima` since v2.60.0 and for `google-dai` since v11.2.0. *
- A parsed version is available as {@link GoogleImaAd.traffickingParameters} (only when using the `google-ima` integration). *
- Available when the {@link Ad.readyState} is `'ready'`. */ traffickingParametersString: string | undefined; /** * List of wrapper ad identifiers as specified in the VAST response. */ wrapperAdIds: string[]; /** * List of wrapper ad systems as specified in the VAST response. */ wrapperAdSystems: string[]; /** * List of wrapper creative identifiers. * * @remarks *
- Starts with the first wrapper ad. */ wrapperCreativeIds: string[]; /** * The url of the chosen media file. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. */ mediaUrl: string | undefined; /** * The content type of the ad. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. *
- For linear ads, the content type is only going to be available after the `'adbegin'` event, when the media file is selected. */ contentType: string | undefined; /** * The identifier of the API framework needed to execute the ad. * * @remarks *
- Available when the {@link Ad.readyState} is `'ready'`. *
- This corresponds with the apiFramework specified in vast. */ apiFramework: string | undefined; /** * The description of the ad from the VAST response. * * @remarks *
- Available since 8.6.0. *
- Available for `google-ima` and `google-dai` integrations only. */ description: string | undefined; } /** * Represents the information regarding the universal identifier of an ad. * * @category Ads * @public */ interface UniversalAdId { /** * The registry associated with cataloging the UniversalAdId of the selected creative for the ad. * * @remarks *
- Returns the registry value, or "unknown" if unavailable. */ adIdRegistry: string; /** * The UniversalAdId of the selected creative for the ad. * * @remarks *
- Returns the id value or "unknown" if unavailable. */ adIdValue: string; } /** * Represents an ad break in the VMAP specification or an ad pod in the VAST specification. * * @category Ads * @public */ interface AdBreak { /** * The identifier of the ad break. * * @remarks *
- For THEOads, this is the interstitial identifier. *
- For Google IMA & DAI, this is the pod index of the ad break. *
- For other integrations, this may be `undefined`. */ id: string | undefined; /** * The integration of the ad break, represented by a value from {@link AdIntegrationKind} * or {@link CustomAdIntegrationKind | the identifier of a custom integration} registered with {@link Ads.registerServerSideIntegration}. * * @remarks *
- The `'theo'` integration naming is deprecated and has been replaced with `'csai'`. */ integration: AdIntegrationKind | CustomAdIntegrationKind | undefined; /** * List of ads which will be played sequentially at the ad break's time offset. */ ads: Ad[] | undefined; /** * The time offset at which content will be paused to play the ad break, in seconds. */ timeOffset: number; /** * The duration of the ad break, in seconds. * * @remarks *
- Ads are lazily loaded. This property becomes available when all ads are loaded. */ maxDuration: number | undefined; /** * The remaining duration of the ad break, in seconds. * * @remarks *
- Ads are lazily loaded. This property becomes available when all ads are loaded. *
- This feature is not available in the Google IMA integration and will default to -1. */ maxRemainingDuration: number | undefined; /** * Additional integration-specific data associated with this ad. */ customData: unknown; } /** * Represents a companion ad which is displayed near the video player. * * @category Ads * @public */ interface CompanionAd { /** * The identifier of the element in which the companion ad should be appended, if available. * * @remarks *
Only available for Google DAI and THEO ads if provided in the VAST. */ adSlotId?: string; /** * The alternative description for the ad. * * @remarks *
- Returns value as reported in the VAST StaticResource. If not specified, it returns an empty string. *
- Returns an empty string for THEO ads if not available. *
- Returns an empty string for Google IMA / Google DAI integrations. */ altText: string; /** * The content of the ad, as HTML. * * @remarks *
- Available for StaticResource and HTMLResource in THEO ad system. *
- Available in the DAI ad system. */ contentHTML: string; /** * The website of the advertisement. * * @remarks *
- Only available for StaticResource if specified by the VAST. Otherwise returns an empty string. */ clickThrough?: string; /** * The height of the ad, in pixels. * * @remarks *
- Only available for IMA ad system and THEO ad system. */ height: number; /** * The URI of the ad content as specified in the VAST file. * * @remarks *
- Only available in the THEO ad system for StaticResource. Otherwise returns an empty string. */ resourceURI: string; /** * The width of the ad, in pixels. * * @remarks *
- Only available for IMA ad system and THEO ad system. */ width: number; } /** * The events fired by the {@link Ads | ads API}. * * @category Ads * @public */ interface AdsEventMap { /** * Fired when an ad break is added. * * @remarks *
- Available since v2.60.0. */ addadbreak: AdBreakEvent<'addadbreak'>; /** * Fired when an ad break is removed. * * @remarks *
- Available since v2.60.0. */ removeadbreak: AdBreakEvent<'removeadbreak'>; /** * Fired when an ad break begins. */ adbreakbegin: AdBreakEvent<'adbreakbegin'>; /** * Fired when an ad break ends. */ adbreakend: AdBreakEvent<'adbreakend'>; /** * Fired when an ad break changes. */ adbreakchange: AdBreakEvent<'adbreakchange'>; /** * Fired when an ad is added. * * @remarks *
- Available since v2.60.0. */ addad: AdEvent<'addad'>; /** * Fired when an ad is updated. * * @remarks *
- Available since v2.60.0. */ updatead: AdEvent<'updatead'>; /** * Fired when an AdBreak is updated. * * @remarks *
- Available since v2.66.0. */ updateadbreak: AdBreakEvent<'updateadbreak'>; /** * Fired when an ad is loaded. */ adloaded: Event<'adloaded'>; /** * Fired when an ad begins. */ adbegin: AdEvent<'adbegin'>; /** * Fired when an ad ends. */ adend: AdEvent<'adend'>; /** * Fired when an ad is skipped. */ adskip: AdSkipEvent; /** * Fired when an ad errors. */ aderror: Event<'aderror'>; /** * Fired when an ad counts as an impression. */ adimpression: AdEvent<'adimpression'>; /** * Fired when an ad reaches the first quartile. */ adfirstquartile: AdEvent<'adfirstquartile'>; /** * Fired when an ad reaches the mid point. */ admidpoint: AdEvent<'admidpoint'>; /** * Fired when an ad reaches the third quartile. */ adthirdquartile: AdEvent<'adthirdquartile'>; /** * Fired when the ad has stalled playback to buffer. * * @remarks *
- only available in the Google IMA integration. */ adbuffering: AdBufferingEvent; /** * Fired when an ads list is loaded. * * @remarks *
- only available in the Google IMA integration. */ admetadata: AdMetadataEvent; /** * Fired when the {@link https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side/reference/js/google.ima.AdsManager | google.ima.AdsManager} is created. * * @remarks *
- only available in the Google IMA integration. */ adsmanagerloaded: AdsManagerLoadedEvent; /** * Fired when the user clicks on an ad's clickthrough element. * * @remarks *
- Available since v11.9.0. */ adclicked: AdEvent<'adclicked'>; } /** * Base type for events related to a single ad. * * @category Ads * @category Events * @public */ interface AdEvent extends Event { /** * The ad. */ readonly ad: Ad; } /** * Fired when an ad is skipped. * * @category Ads * @category Events * @public */ interface AdSkipEvent extends AdEvent<'adskip'> { /** * The amount of time that was played before the ad was skipped, as a fraction between 0 and 1. */ readonly playedPercentage: number; } /** * Base type for events related to an ad break. * * @category Ads * @category Events * @public */ interface AdBreakEvent extends Event { /** * The ad break. */ readonly adBreak: AdBreak; } /** * The API for advertisements. * * @remarks *
- Integrates with `'csai'`, `'google-ima'`, `'google-dai'`, `'freewheel'` or `'theoads'`. * * @category Ads * @public */ interface Ads extends EventDispatcher { /** * Whether a linear ad is currently playing. */ playing: boolean; /** * The currently playing ad break. */ readonly currentAdBreak: AdBreak | null; /** * List of currently playing ads. */ readonly currentAds: Ad[]; /** * List of ad breaks which still need to be played. */ readonly scheduledAdBreaks: AdBreak[]; /** * List of ads which still need to be played. */ readonly scheduledAds: Ad[]; /** * The Google DAI API. * * @remarks *
- Only available with the feature `'google-dai'`. */ readonly dai?: GoogleDAI; /** * Add an ad break request. * * @remarks *
- Available since v2.18.0. *
- Prefer scheduling ad breaks up front through {@link SourceConfiguration.ads}. * * @param adDescription - Describes the ad break to be scheduled. */ schedule(adDescription: AdDescription): void; /** * Skip the current linear ad. * * @remarks *
- This will have no effect when the current linear ad is (not yet) skippable. */ skip(): void; /** * Seek to a point in the main content timeline. * * @remarks *
- Available since v9.4.0. *
- Only supported for the `csai` integration. *
- This will have no effect when `allowSkipAdBreak` is not set to `true` in the `AdsConfiguration`. */ skipAdBreak(target?: number): void; /** * Register a custom advertisement integration. * * This allows you to integrate with third-party advertisement providers, * and have them report their ads and ad-related events through the THEOplayer {@link Ads} API. * * @param integrationId * An identifier of the integration. * @param integrationFactory * Factory that will construct an {@link ServerSideAdIntegrationHandler} for this integration. */ registerServerSideIntegration(integrationId: CustomAdIntegrationKind, integrationFactory: ServerSideAdIntegrationFactory): void; } /** * The type of ad source: *
- `'vast'`: The source is a VAST resource. *
- `'vmap'`: The source is a VMAP resource. *
- `'adrule'`: The source is an Ad Rule resource. * * @remarks *
- An ad rule is a simplified VMAP alternative only available in the Google IMA integration. * * @category Ads * @public */ type AdSourceType = 'vast' | 'vmap' | 'adrule'; /** * Describes the source of the ad. * * @category Ads * @public */ interface AdSource { /** * The URL of the ad resource. */ src: string; /** * The type of ad resource. * * @defaultValue 'vmap' when set through {@link SourceConfiguration.ads} without a time offset, otherwise 'vast'. */ type?: AdSourceType; } /** * Describes an ad break request. * * @category Ads * @public */ interface AdDescription { /** * The integration of the ad, represented by a value from {@link AdIntegrationKind} * or {@link CustomAdIntegrationKind | the identifier of a custom integration} registered with {@link Ads.registerServerSideIntegration}. * * @defaultValue `'csai'` */ integration?: AdIntegrationKind | CustomAdIntegrationKind; /** * Whether the ad replaces playback of the content. * * @remarks *
- When the ad ends, the content will resume at the ad break's offset plus its duration. *
- Available for `theoads` since v11.2.0. * * @defaultValue *
- `true` for live content and `theoads` VOD content. *
- `false` for VOD content. */ replaceContent?: boolean; /** * A source which contains the location of ad resources to be scheduled. * * @remarks *
- Important: This should *not* be an array of sources. *
- VPAID support is limited to the `'google-ima'` integration. *
- Not specifying this property should only happen when using a third party ad integration that uses another system of specifying which ads to schedule. */ sources?: string | AdSource; /** * Offset after which the ad break will start. * * Possible formats: *
- A number for the offset in seconds. *
- `'start'` for a preroll. *
- `'end'` for a postroll. *
- `'HH:MM:SS.mmm'` for a timestamp in the playback window. *
- A percentage string (XX%) for a proportion of the content duration. * * @remarks *
- A timestamp which is not in the playback window will result in the ad break not being started. *
- Do NOT set for VMAP ads. VMAP resources will ignore this value as they contain an internal offset. https://www.theoplayer.com/docs/theoplayer/how-to-guides/ads/how-to-set-up-vast-and-vmap/#vmap *
- Since 2.18, numbers are supported for the Google IMA integration, since 2.21 other formats as well. * * @defaultValue `'start'` * */ timeOffset?: string | number; } /** * Describes a SpotX ad break request. * * @remarks *
- Available since v2.13.0. * * @example * ``` * { * integration: 'spotx', * id: 123456, * cacheBuster: true, * app: { * bundle: 'com.exampleapps.example', * name: 'My CTV App' * }, * device: { * ifa: '38400000-8cf0-11bd-b23e-10b96e40000d', * ua: 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1', * geo: { * lat: -24.378528, * lon: -128.325119 * }, * dnt: 1, * lmt: 1, * }, * custom: { * category: ['category1', 'category2'], * somekey: 'somevalue' * } * user: { * yob: 1984, * gender: 'm' * } * } * ``` * * @category Ads * @public */ interface SpotXAdDescription extends AdDescription { /** * The integration of the ad break. */ integration: 'spotx'; /** * The identifier of the ad break requested from SpotX. */ id: number | string; /** * The maximum duration of the ad, in seconds. * * @defaultValue No maximum duration. */ maximumAdDuration?: number | string; /** * The URL of the content page. */ contentPageUrl?: string; /** * The IP address of the viewer. */ ipAddress?: string; /** * Whether the ad break request should contain a cache buster. * * @remarks *
- A cache buster adds a query parameter 'cb' with a random value to circumvent browser caching mechanisms. */ cacheBuster?: boolean; /** * A source URL which contains the location of ad resources to be scheduled. * * @remarks *
- This will override the generated URL. */ sources?: string; /** * A record of query string parameters added to the SpotX ad break request. * Each entry contains the parameter name with associated value. * * @remarks *
- Available since v2.38.0. */ queryParameters?: SpotxQueryParameter; /** * Custom SpotX data. * * @deprecated Superseded by {@link SpotXAdDescription.queryParameters | queryParameters.custom}. */ custom?: SpotxData; /** * Application specific SpotX data. * * @deprecated Superseded by {@link SpotXAdDescription.queryParameters | queryParameters.app}. */ app?: SpotxData; /** * Device specific SpotX data. * * @deprecated Superseded by {@link SpotXAdDescription.queryParameters | queryParameters.device}. */ device?: SpotxData; /** * User specific SpotX data. * * @deprecated Superseded by {@link SpotXAdDescription.queryParameters | queryParameters.user}. */ user?: SpotxData; } /** * Describes a Google IMA ad break request. * * @category Ads * @public */ interface IMAAdDescription extends AdDescription { /** * The integration of the ad break. */ integration: 'google-ima'; /** * The source of the ad * * @remarks *
- VAST, VMAP and VPAID are supported. *
- Overlay ads and banners are only displayed if the container element (the player) is big enough in pixels. */ sources: string | AdSource; /** * Optional settings object for mapping verification vendors (google.ima.OmidVerificationVendor) to OMID Access Modes (google.ima.OmidAccessMode). */ omidAccessModeRules?: Record; } /** * The possible ad unit types, represented by a value from the following list: *
- `'preroll'`: The linear ad will play before the content started. *
- `'midroll'`: The linear ad will play at a time offset during the content. *
- `'postroll'`: The linear ad will play after the content ended. *
- `'overlay'`: The non-linear ad. * * @category Ads * @public */ type FreeWheelAdUnitType = 'preroll' | 'midroll' | 'postroll' | 'overlay'; /** * Represents a FreeWheel cue. * * @category Ads * @public */ interface FreeWheelCue { /** * The ad unit type. */ adUnit: FreeWheelAdUnitType; /** * Offset after which the ad break will start, in seconds. */ timeOffset: number; } /** * Describes a FreeWheel ad break request. * * @remarks *
- Available since v2.42.0. * * @category Ads * @public */ interface FreeWheelAdDescription extends AdDescription { /** * The integration of the ad break. */ integration: 'freewheel'; /** * The FreeWheel ad server URL. */ adServerUrl: string; /** * The duration of the asset, in seconds. * * @remarks *
- Optional for live assets. */ assetDuration?: number; /** * The identifier of the asset. * * @remarks *
- Generated by FreeWheel CMS when an asset is uploaded. */ assetId?: string; /** * The network identifier which is associated with a FreeWheel customer. */ networkId: number; /** * The server side configuration profile. * * @remarks *
- Used to indicate desired player capabilities. */ profile: string; /** * The identifier of the video player's location. */ siteSectionId?: string; /** * List of cue points. * * @remarks *
- Not available in all FreeWheel modes. */ cuePoints?: FreeWheelCue[]; /** * A record of query string parameters added to the FreeWheel ad break request. * Each entry contains the parameter name with associated value. */ customData?: Record; } /** * Represents a geographical location. * * @category Ads * @public */ interface Geo { /** * The latitude of this location. */ readonly lat: number; /** * The longitude of this location. */ readonly lon: number; } /** * A record of SpotX query string parameters. * Each entry contains the parameter name with associated value. * * @category Ads * @public */ interface SpotxData { [key: string]: string | number | boolean | string[] | Geo; } /** * A record of SpotX query string parameters which can be a nested structure. * Each entry contains the parameter name with associated value. * * @category Ads * @public */ interface SpotxQueryParameter { [key: string]: string | number | boolean | string[] | Geo | SpotxData | SpotxData[]; } /** * The integration of an ad or ad break, represented by a value from the following list: *
- `'csai'`: Default CSAI ad playback. *
- `'theo'`: Old naming for `'csai'` - Default ad playback. (Deprecated) *
- `'google-ima'`: {@link https://developers.google.com/interactive-media-ads/docs/sdks/html5/client-side | Google IMA} pre-integrated ad playback. *
- `'google-dai'`: {@link https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/html5 | Google DAI} pre-integrated ad playback. *
- `'spotx'`: {@link https://developer.spotxchange.com/ | SpotX} pre-integrated ad playback. *
- `'freewheel'`: {@link https://vi.freewheel.tv/ | FreeWheel} pre-integrated ad playback. *
- `'mediatailor'`: {@link https://aws.amazon.com/mediatailor/ | MediaTailor} pre-integrated ad playback. *
- `'chromecast'`: {@link https://developers.google.com/cast/docs/web_receiver/ad_breaks | Chromecast} ads playing on a remote receiver. *
- `'theoads'`: {@link https://optiview.dolby.com/docs/ads/ | OptiView Ads} (previously THEOads) pre-integrated ad playback. * * @remarks *
- An empty string will default to `'csai'`. * * @category Ads * @public */ type AdIntegrationKind = '' | 'csai' | 'theo' | 'google-ima' | 'spotx' | 'freewheel' | 'theoads'; /** * The identifier of a custom ad integration registered with {@link Ads.registerServerSideIntegration}. * * @category Ads */ type CustomAdIntegrationKind = string & {}; /** * The iframe policies for VPAID ads, represented by a value from the following list: *
- `'enabled'`: Ads will load in a cross domain iframe. This disables access to the site via JavaScript. Ads that require a friendly iframe will fail to play. *
- `'insecure'`: Ads will load in a friendly iframe. This allows access to the site via JavaScript. *
- `'disabled'`: Ads will error when requested. * * @category Ads * @public */ type VPAIDMode = 'enabled' | 'insecure' | 'disabled'; /** * Describes an ad break request. * * @category Ads * @public */ interface CsaiAdDescription extends AdDescription { /** * The integration of the ad break. * * @defaultValue `'csai'` * @remarks *
- The `'theo'` integration naming is deprecated and has been replaced with `'csai'`. */ integration?: 'csai' | 'theo'; /** * The source of the ad * * @remarks *
- Only supports VAST and VMAP. */ sources: string | AdSource; /** * Offset after which the ad break can be skipped. * * @remarks *
- A timestamp which is not in the playback window will result in the ad break not being started. *
- VMAP resources will ignore this value as they contain an internal offset. * * Possible formats: *
- A number for the offset in seconds. *
- `'start'` for a preroll. *
- `'end'` for a postroll. *
- `'HH:MM:SS.mmm'` for a timestamp in the playback window. *
- A percentage string (XX%) for a proportion of the content duration. * * @defaultValue `'start'` */ skipOffset?: string | number; } /** * Helper type that represents either an ArrayBuffer or an ArrayBufferView. * Inspired by {@link https://webidl.spec.whatwg.org/#common-BufferSource}. * * @public */ type BufferSource = ArrayBufferView | ArrayBuffer; /** * Describes the key system configuration. * * @category Source * @category Content Protection * @public */ interface KeySystemConfiguration { /** * Property to indicate whether the ability to persist state is required. This includes session data and any other type of state. The player will forward this information to the CDM when requesting access to the media key system. * * Available values are: * - "required": This will instruct the player to make the key sessions persistent. * - "optional": Choice of making use of a persistent key session is up to the player. * - "not-allowed": A temporary key session will be used. */ persistentState?: 'required' | 'optional' | 'not-allowed'; /** * Used to indicate if media key sessions can be shared across different instances, for example different browser profiles, player instances or applications. The player will forward this information to the CDM when requesting access to the media key system. * Available values are: * - “required” * - “optional” * - “not-allowed” */ distinctiveIdentifier?: 'required' | 'optional' | 'not-allowed'; /** * Allows to configure the robustness level required for audio data. The robustness level can be used to define the DRM security level. If the security level requested is not available on the platform, playback will fail. * * Following values are supported for Widevine: * - "": Lowest security level * - "SW_SECURE_CRYPTO": Secure decryption in software is required. This matches Widevine L3. * - "SW_SECURE_DECODE": Media data is to be decoded securely in software. This matches Widevine L3. * - "HW_SECURE_CRYPTO": Secure decryption in hardware is required. This matches Widevine L2. * - "HW_SECURE_DECODE": Media data is to be decoded securely in hardware. This matches Widevine L1. * - "HW_SECURE_ALL": The media pipeline must be decrypted and decoded securely in hardware. This matches Widevine L1. */ audioRobustness?: string; /** * Allows to configure the robustness level required for video data. The robustness level can be used to define the DRM security level. If the security level requested is not available on the platform, playback will fail. * * Following values are supported for Widevine: * * - "": Lowest security level * - "SW_SECURE_CRYPTO": Secure decryption in software is required. This matches Widevine L3. * - "SW_SECURE_DECODE": Media data is to be decoded securely in software. This matches Widevine L3. * - "HW_SECURE_CRYPTO": Secure decryption in hardware is required. This matches Widevine L2. * - "HW_SECURE_DECODE": Media data is to be decoded securely in hardware. This matches Widevine L1. * - "HW_SECURE_ALL": The media pipeline must be decrypted and decoded securely in hardware. This matches Widevine L1. */ videoRobustness?: string; /** * The licence acquisition URL. * * @remarks *
- If provided, the player will send license requests for the intended DRM scheme to the provided value. *
- If not provided, the player will use the default license acquisition URLs. */ licenseAcquisitionURL?: string; /** * Record of HTTP headers for the licence acquisition request. * Each entry contains a header name with associated value. */ headers?: { [headerName: string]: string; }; /** * Whether the player is allowed to use credentials for cross-origin requests. * * @remarks *
- Credentials are cookies, authorization headers or TLS client certificates. * * @defaultValue `false` */ useCredentials?: boolean; /** * Record of query parameters for the licence acquisition request. * Each entry contains a query parameter name with associated value. */ queryParameters?: { [key: string]: any; }; /** * The certificate for the key system. This can be either an ArrayBuffer or Uint8Array containing the raw certificate bytes or a base64-encoded variant of this. */ certificate?: BufferSource | string; } /** * The type of the licence, represented by a value from the following list: *
- `'temporary'` *
- `'persistent'` * * @category Source * @category Content Protection * @public */ type LicenseType = 'temporary' | 'persistent'; /** * Describes the FairPlay key system configuration. * * @category Source * @category Content Protection * @public */ interface FairPlayKeySystemConfiguration extends KeySystemConfiguration { /** * The URL of the certificate. */ certificateURL?: string; } /** * Describes the PlayReady key system configuration. * * @category Source * @category Content Protection * @public */ interface PlayReadyKeySystemConfiguration extends KeySystemConfiguration { /** * Custom data which will be passed to the CDM. */ customData?: string; } /** * Describes the Widevine key system configuration. * * @category Source * @category Content Protection * @public */ type WidevineKeySystemConfiguration = KeySystemConfiguration; /** * Describes the ClearKey key system configuration. * * @category Source * @category Content Protection * @public */ interface ClearkeyKeySystemConfiguration extends KeySystemConfiguration { /** * List of decryption keys. */ keys?: ClearkeyDecryptionKey[]; } /** * Describes the ClearKey decryption key. * * @category Source * @category Content Protection * @public */ interface ClearkeyDecryptionKey { /** * The identifier of the key. * * @remarks *
- This is a base64url encoding of the octet sequence containing the key ID. *
- See {@link https://www.w3.org/TR/encrypted-media/#clear-key-license-format | Clear Key License Format}. */ id: string; /** * The value of the key. * * @remarks *
- The base64url encoding of the octet sequence containing the symmetric key value. *
- See {@link https://www.w3.org/TR/encrypted-media/#clear-key-license-format | Clear Key License Format}. */ value: string; } /** * Describes the AES128 key system configuration. * * @category Source * @category Content Protection * @public */ interface AES128KeySystemConfiguration { /** * Whether the player is allowed to use credentials for cross-origin requests. * * @remarks *
- Credentials are cookies, authorization headers or TLS client certificates. * * @defaultValue `false` */ useCredentials?: true; } /** * Describes the configuration of the DRM. * * @category Source * @category Content Protection * @public */ interface DRMConfiguration { /** * The identifier of the DRM integration. */ integration?: string; /** * The configuration of the FairPlay key system. */ fairplay?: FairPlayKeySystemConfiguration; /** * The configuration of the PlayReady key system. */ playready?: PlayReadyKeySystemConfiguration; /** * The configuration of the Widevine key system. */ widevine?: WidevineKeySystemConfiguration; /** * The configuration of the ClearKey key system. */ clearkey?: ClearkeyKeySystemConfiguration; /** * The configuration of the AES key system. */ aes128?: AES128KeySystemConfiguration; /** * An object of key/value pairs which can be used to pass in specific parameters related to a source into a * {@link ContentProtectionIntegration}. */ integrationParameters?: { [parameterName: string]: any; }; /** * An ordered list of URNs of key systems as specified by {@link https://dashif.org/identifiers/content_protection/}, or one of the following identifiers: * * `"widevine"` alias for `"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"` * `"fairplay"` alias for `"urn:uuid:94ce86fb-07bb-4b43-adb8-93d2fa968ca2"` * `"playready"` alias for `"urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95"` * * The first key system in this list which is supported on the given platform will be used for playback. * * Default value is ['widevine', 'playready', 'fairplay']. */ preferredKeySystems?: Array; /** * A flag that affects HbbTV enabled devices and indicates whether the OIPF DRM agent should be used for handling DRM protection, * even when EME is available. * * Default value is false. */ useOipfDrmAgent?: boolean; /** * Record of default query parameters for the license acquisition request. * Each entry contains a query parameter name with associated value. * * @remarks *
- These parameters will be merged with any query parameters specified in * the individual key system configurations, with the latter taking precedence. */ queryParameters?: { [key: string]: any; }; } /** * The id of a key system. Possible values are 'widevine', 'fairplay' and 'playready'. * * @category Source * @category Content Protection * @public */ type KeySystemId = 'widevine' | 'fairplay' | 'playready'; /** * The identifier of the Google DAI integration. * * @category Source * @category SSAI * @public */ type GoogleDAISSAIIntegrationID = 'google-dai'; /** * The type of the stream requested from Google DAI, represented by a value from the following list: *
- `'live'`: The requested stream is a live stream. *
- `'vod'`: The requested stream is a video-on-demand stream. * * @category Source * @category SSAI * @public */ type DAIAvailabilityType = 'vod' | 'live'; /** * Represents a configuration for server-side ad insertion with the Google DAI pre-integration. * * @remarks *
- Available since v2.30.0. * * @category Source * @category SSAI * @public */ interface GoogleDAIConfiguration extends ServerSideAdInsertionConfiguration { /** * The type of the requested stream. */ readonly availabilityType?: DAIAvailabilityType; /** * The identifier for the SSAI pre-integration. */ integration: GoogleDAISSAIIntegrationID; /** * The authorization token for the stream request. * * @remarks *
- If present, this token is used instead of the API key for stricter content authorization. *
- The publisher can control individual content streams authorizations based on this token. *
- See {@link https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/html5/reference/js/StreamRequest#authToken} * for more information. */ authToken?: string; /** * The API key for the stream request. * * @remarks *
- This key is used to verify applications that are attempting to access the content. *
- This key is configured through the Google Ad Manager UI. *
- See {@link https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/html5/reference/js/StreamRequest#apiKey} * for more information. */ apiKey: string; /** * The ad tag parameters added to stream request. * * @remarks *
- Each entry contains the parameter name with associated value. *
- See {@link https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/html5/reference/js/StreamRequest#adTagParameters} * for more information. * * Valid parameters: *
- {@link https://support.google.com/admanager/answer/7320899 | Supply targeting parameters to your stream} *
- {@link https://support.google.com/admanager/answer/7320898 | Override stream variant parameters} */ adTagParameters?: Record; /** * The identifier for a stream activity monitor session. * * @remarks *
- See {@link https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/html5/reference/js/StreamRequest#streamActivityMonitorId} * for more information. */ streamActivityMonitorID?: string; /** * The network code for the publisher making this stream request. * * @remarks *
- See {@link https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/html5/reference/js/StreamRequest#networkCode} * for more information. */ networkCode?: string; /** * Optional settings object for mapping verification vendors (google.ima.OmidVerificationVendor) to OMID Access Modes (google.ima.OmidAccessMode). * * @remarks *
- See {@link https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/html5/reference/js/StreamRequest#omidAccessModeRules} * for more information. */ omidAccessModeRules?: Record; /** * A flag to indicate that the DAI SDK should send an encrypted nonce to the DAI servers. * * @remarks *
- See {@link https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/html5/sending-ad-signals-through-third-party-servers} * for more information. *
- Available since 9.2.0. */ enableNonce?: boolean; } /** * Represents a configuration for server-side ad insertion with the Google DAI pre-integration for a Live media stream. * * @remarks *
- Available since v2.30.0. * * @category Source * @category SSAI * @public */ interface GoogleDAILiveConfiguration extends GoogleDAIConfiguration { /** * The type of the requested stream. */ readonly availabilityType: 'live'; /** * The identifier for the video content source for live streams. * * @remarks *
- This property is required for live streams. *
- The asset key can be found in the Google Ad Manager UI. */ assetKey: string; } /** * Represents a configuration for server-side ad insertion with the Google DAI pre-integration for a VOD media stream. * * @remarks *
- Available since v2.30.0. * * @category Source * @category SSAI * @public */ interface GoogleDAIVodConfiguration extends GoogleDAIConfiguration { /** * The type of the requested stream. */ readonly availabilityType: 'vod'; /** * The identifier for the publisher content for on-demand streams. * * @remarks *
- The publisher content comes from a CMS. *
- This property is required for on-demand streams. */ contentSourceID: string; /** * The identifier for the video content source for on-demand streams. * * @remarks *
- This property is required for on-demand streams. */ videoID: string; } /** * Represents a media resource with a Google DAI server-side ad insertion request. * * @category Source * @category SSAI * @public */ interface GoogleDAITypedSource extends TypedSource { /** * The content type (MIME type) of the media resource, represented by a value from the following list: *
- `'application/dash+xml'`: The media resource is an MPEG-DASH stream. *
- `'application/x-mpegURL'` or `'application/vnd.apple.mpegurl'`: The media resource is an HLS stream. */ type: string; ssai: GoogleDAIVodConfiguration | GoogleDAILiveConfiguration; } /** * The identifier of a server-side ad insertion pre-integration, represented by a value from the following list: *
- `'google-dai'`: The configuration with this identifier is a {@link GoogleDAIConfiguration} * * @category Source * @category SSAI * @public */ type SSAIIntegrationId = GoogleDAISSAIIntegrationID; /** * Represents a configuration for server-side ad insertion (SSAI). * * @remarks *
- Available since v2.12.0. * * @category Source * @category SSAI * @public */ interface ServerSideAdInsertionConfiguration { /** * The identifier for the SSAI integration. */ integration: SSAIIntegrationId | CustomAdIntegrationKind; } /** * The stereo mode of the VR integration, represented by a value from the following list: *
- `''`: No stereo mode *
- `'horizontal'`: The two viewpoints are in a side-by-side layout. The view for the left eye is in the left half of the video frame, the view for the right eye is in the right half of the video frame. *
- `'vertical'`: The two viewpoints are in a top-bottom layout. The view for the left eye is in the upper half of the video frame, the view for the right eye is in the lower half of the video frame. * * @category VR * @public */ type VRStereoMode = '' | 'horizontal' | 'vertical'; /** * The panorama mode of the VR content, represented by a value from the following list: *
- `''`: No panorama mode. *
- `'360'`: The video contains content with a full 360 degree field of view. *
- `'180'`: The video contains content with a 180 degree field of view. * * @category VR * @public */ type VRPanoramaMode = '' | '360' | '180'; /** * Describes the configuration of the virtual reality feature of a source. * * @remarks *
- Available since v2.12.0. *
- See {@link VR | the VR API} to control display of VR videos. * * @category VR * @public */ interface VRConfiguration { /** * Whether the source contains 360° video content. * * @defaultValue `false` */ '360'?: boolean; /** * The panorama mode of the media. * * @remarks *
- If the "360" property is set to true, panoramaMode is ignored and the content will be displayed as 360 degrees panorama. * * @defaultValue `undefined` */ panoramaMode?: VRPanoramaMode; /** * The stereoscopic mode of the media. * * @defaultValue `''` */ stereoMode?: VRStereoMode; /** * Whether the source plays using native VR. * * @remarks *
- This property is only available for iOS. * * @defaultValue `false` */ nativeVR?: boolean; } /** * Describes the configuration of the Cast integrations. * * @category Casting * @public */ interface CastConfiguration { /** * The Chromecast configuration. * * @defaultValue A {@link ChromecastConfiguration} with default values. */ chromecast?: ChromecastConfiguration; /** * The join strategy of the player. * * @defaultValue `'manual'` */ strategy?: JoinStrategy; } /** * The join strategy, represented by a value from the following list: *
- `'auto'` : The player will automatically join a cast session if one exists when play is called. Otherwise it will prompt the user with all available devices. *
- `'manual'` : The player will take over an existing session if there is one and the cast button is clicked. Otherwise it will prompt the user with all available devices. *
- `'disabled'` : The player is not affected by cast sessions and is not castable. * * @category Casting * @public */ type JoinStrategy = 'auto' | 'manual' | 'disabled'; /** * Describes the configuration of the Chromecast integration. * * @category Casting * @public */ interface ChromecastConfiguration { /** * The identifier of a custom Chromecast receiver app. * * @defaultValue The default THEOplayer receiver app ID: `8E80B9CE`. This is a Shaka-based CAF receiver. Use `44BAE7D1` for an MPL-based CAF receiver for THEOplayer. */ appID?: string; } /** * The strategy of the action after skipping ads, represented by a value from the following list: *
- `'play-all'`: Plays all the ad breaks skipped due to a seek. *
- `'play-none'`: Plays none of the ad breaks skipped due to a seek. *
- `'play-last'`: Plays the last ad break skipped due to a seek. * * @category Uplynk * @public */ type SkippedAdStrategy = 'play-all' | 'play-none' | 'play-last'; /** * Describes the configuration of the Uplynk integration. * * @category Uplynk * @public */ interface UplynkConfiguration { /** * The offset after which an ad break may be skipped, in seconds. * * @remarks * If the offset is -1, the ad is unskippable. * If the offset is 0, the ad is immediately skippable. * Otherwise it must be a positive number indicating the offset. * * @defaultValue `-1` */ defaultSkipOffset?: number; /** * The ad skip strategy which is used when seeking over ads. * * @defaultValue `'play-none'`. */ onSeekOverAd?: SkippedAdStrategy; /** * The Uplynk UI configuration. * * @remarks * Only available with the features `'uplynk'` and `'ui'`. */ ui?: UplynkUiConfiguration; } /** * Describes the UI configuration of the Uplynk integration. * * @category Uplynk * @public */ interface UplynkUiConfiguration { /** * Whether an up next content countdown is shown on the UI. * * @remarks *
- This countdown starts ten seconds before the up next asset starts. * * @defaultValue `true` */ contentNotification?: boolean; /** * Whether an ad break skip button is shown on the UI. * * @remarks *
- When unskippable, a banner with countdown is shown instead. * * @defaultValue `true` */ adNotification?: boolean; /** * Whether the seek bar is supplemented with asset dividers on the UI. * * @defaultValue `true` */ assetMarkers?: boolean; /** * Whether the seek bar is supplemented with marked areas in which ad breaks are present on the UI. * * @defaultValue `true` */ adBreakMarkers?: boolean; } /** * Describes the ABR configuration for a specific source. * * @category Source * @category ABR * @public */ interface SourceAbrConfiguration { /** * A list of preferred audio codecs which will be used by the ABR algorithm for track selection, if the codec is supported. * */ preferredAudioCodecs?: string[]; /** * A list of preferred video codecs which will be used by the ABR algorithm for track selection, if the codec is supported. * * @remarks *
- If unset, Dolby Vision and HEVC are preferred over other codecs at the initial variant stream selection. *
- Set an empty list to disable any codec preference. */ preferredVideoCodecs?: string[]; /** * Whether to restrict the ABR algorithm to only select qualities whose resolution fits within the player's rendered size. * * @remarks *
- If `true`, only select qualities that fit within the player's size. *
- If `false`, allow selecting qualities that are larger than the player's size. *
- If unset (default), then apply the restriction only when playing on a mobile device. * * @defaultValue `undefined` */ restrictToPlayerSize?: boolean; } /** * Object containing values used for the player's retry mechanisms. * * @category Player * @public */ interface RetryConfiguration { /** * The maximum amount of retries before the player throws a fatal error. * Defaults to `Infinity`. */ maxRetries?: number; /** * The initial delay in milliseconds before a retry request occurs. * Exponential backoff will be applied on this value. * Defaults to `200`, however the default value is `1000` for Millicast sources. * `1000` is the minimum allowed value for Millicast sources. */ minimumBackoff?: number; /** * The maximum amount of delay in milliseconds between retry requests. * Defaults to `30000`. */ maximumBackoff?: number; } /** * The values that can be set to define hardware resources on Sony PlayStation® 5. * * @category Player * @public */ type PlayStation5PlayMode = '2K' | '4K'; /** * Describes the configuration that is specific for playback on Sony PlayStation® 5. * * @category Player * @public */ interface PlayStation5Configuration { /** * Used to define hardware resources when playing multiple videos at the same time. The PlayStation® 5 supports playing a single video up to 4K * at 60fps, or two videos with a combined resolution up to 4K at 30fps. * * - When playing a single video, this can be omitted (or set to `'4K'`). * - When playing two videos, this can be set to `'4K'` if the combined resolution is less than 4K. Otherwise, one or both videos must be * set to `'2K'`. * - When playing three or more videos, this must be set to `'2K'`. * * Default: `'4K'` */ playMode?: PlayStation5PlayMode; /** * Indicates if audio pass-through is enabled. * * In pass-through mode, the PlayStation® 5 will forward the compressed audio as-is to the A/V receiver for playback. * * This mode is only supported when there is only a single video player on the page. When there can be multiple video players at the same time, * this value must be set to false, so the PlayStation® can decompress and mix the audio before sending it to the A/V receiver. * * Default: `true` */ passThrough?: boolean; } /** * Describes the CMCD (Common Media Client Data) configuration for event mode reporting at the player level. * * @remarks *
- Available since v11.4.0. *
- This configuration is only used for event mode reporting only, for now. For request mode, you should use the * CMCD connector on GitHub (https://github.com/THEOplayer/web-connectors/tree/main/cmcd). *
- This configuration is set at the player level. For source-level configuration, see {@link CmcdSourceConfiguration}. * * @category CMCD * @public */ interface CmcdConfiguration { /** * An external session ID that can be used to identify the current playback session. */ externalSessionId?: string; /** * A user ID that can be used to identify the user. */ userId?: string; /** * A list of CMCD endpoints to which events should be sent. */ eventEndpoints?: CmcdEndpointConfiguration[]; } /** * Describes the CMCD (Common Media Client Data) configuration for event mode reporting at the source level. * * @remarks *
- Available since v11.4.0. *
- This configuration is only used for event mode reporting only, for now. For request mode, you should use the * CMCD connector on GitHub (https://github.com/THEOplayer/web-connectors/tree/main/cmcd). *
- This extends the player-level {@link CmcdConfiguration} by additionally allowing a session ID to be specified * per source. Source-level values take precedence over player-level values for overlapping fields, * except for `eventEndpoints` which are merged (both player and source endpoints receive events). * * @category CMCD * @public */ interface CmcdSourceConfiguration extends CmcdConfiguration { /** * A GUID identifying the current playback session. * * @remarks * A playback session typically consists of the playback of a single media * asset along with accompanying content such as advertisements. This session may comprise the playback of primary content * combined with interstitial content. This session is being played on a single device. The maximum length is 64 characters. * It is RECOMMENDED to conform to the UUID specification (https://tools.ietf.org/html/rfc4122). */ sessionId?: string; } /** * Configuration for a CMCD endpoint. * * @category CMCD * @public */ interface CmcdEndpointConfiguration { /** * The URL of the CMCD endpoint. */ url: string; } /** * Describes a player's configuration. * * @category Player * @public */ interface PlayerConfiguration { /** * The directory in which the THEOplayer library worker files are located. * These worker files are theoplayer.d.js, theoplayer.e.js, theoplayer.p.js. * * @remarks *
- This parameter is required when using a HLS source and has no default. * * @example * `'/lib/theoplayer/'` */ libraryLocation?: string; /** * Whether THEOplayer will be used in an iframe. * * @defaultValue `false` */ isEmbeddable?: boolean; /** * The muted autoplay policy. * * @remarks *
- The muted autoplay policy is impacted by this property and {@link SourceConfiguration.mutedAutoplay}. * * @defaultValue `'none'`. */ mutedAutoplay?: MutedAutoplayConfiguration; /** * An override for the autoplay capability of the platform. * * @remarks * By default, the player attempts to auto-detect the platform's autoplay capabilities, * for example by calling [`navigator.getAutoplayPolicy()`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getAutoplayPolicy) * or by attempting to autoplay an off-screen `