diff --git a/.changeset/khaki-clocks-flow.md b/.changeset/khaki-clocks-flow.md new file mode 100644 index 00000000..ffd707ac --- /dev/null +++ b/.changeset/khaki-clocks-flow.md @@ -0,0 +1,6 @@ +--- +"@theoplayer/yospace-connector-web": minor +--- + +Added `YospaceServerSideAdInsertionConfiguration` type definition to the connector, +superseding the type defined by the THEOplayer Web SDK. diff --git a/yospace/src/index.ts b/yospace/src/index.ts index f6de165a..beb02b27 100644 --- a/yospace/src/index.ts +++ b/yospace/src/index.ts @@ -1,4 +1,5 @@ export * from './integration/YospaceConnector'; +export * from './integration/YospaceConfiguration'; export { AnalyticEventObserver, SessionErrorCode } from './yospace/AnalyticEventObserver'; export * from './yospace/AdBreak'; export { SessionProperties } from './yospace/SessionProperties'; diff --git a/yospace/src/integration/YospaceConfiguration.ts b/yospace/src/integration/YospaceConfiguration.ts new file mode 100644 index 00000000..22d73b03 --- /dev/null +++ b/yospace/src/integration/YospaceConfiguration.ts @@ -0,0 +1,32 @@ +import type { ServerSideAdInsertionConfiguration } from 'theoplayer'; + +/** + * The identifier of the Yospace integration. + */ +export type YospaceSSAIIntegrationID = 'yospace'; + +/** + * The type of the Yospace stream, represented by a value from the following list: + * - `'live'`: The stream is a live stream. + * - `'livepause'`: The stream is a live stream with a large DVR window. + * - `'nonlinear'`: The stream is a Non-Linear Start-Over stream. + * - `'vod'`: The stream is a video-on-demand stream. + */ +export type YospaceStreamType = 'vod' | 'live' | 'livepause' | 'nonlinear'; + +/** + * Represents a configuration for server-side ad insertion with Yospace using the {@link YospaceConnector}. + */ +export interface YospaceServerSideAdInsertionConfiguration extends ServerSideAdInsertionConfiguration { + /** + * The identifier for the Yospace integration. + */ + integration: YospaceSSAIIntegrationID; + + /** + * The type of the requested stream. + * + * @defaultValue `'live'` + */ + streamType?: YospaceStreamType; +} diff --git a/yospace/src/integration/YospaceConnector.ts b/yospace/src/integration/YospaceConnector.ts index 7c9dde11..f55e8176 100644 --- a/yospace/src/integration/YospaceConnector.ts +++ b/yospace/src/integration/YospaceConnector.ts @@ -27,8 +27,12 @@ export class YospaceConnector implements EventDispatcher { * * As of THEOplayer 7.4.0, you can also set `player.source` directly instead of using this method. * - * @param sourceDescription the source that will be used to create the Yospace session. - * @param sessionProperties the properties that will be used set to customize the Yospace session. + * @param sourceDescription + * The source that will be used to create the Yospace session. + * This should have at least one {@link SourceDescription.sources | source} whose {@link TypedSource.ssai} + * is a {@link YospaceServerSideAdInsertionConfiguration}. + * @param sessionProperties + * The properties that will be used set to customize the Yospace session. * @throws `Error` if the Yospace Ad Management SDK is not available. * @throws `Error` if something goes wrong in setting up the session. */ diff --git a/yospace/src/integration/YospaceUIHandler.ts b/yospace/src/integration/YospaceUIHandler.ts index c14d1004..addf6bb3 100644 --- a/yospace/src/integration/YospaceUIHandler.ts +++ b/yospace/src/integration/YospaceUIHandler.ts @@ -1,4 +1,3 @@ -import { YospaceSessionManager } from '../yospace/YospaceSessionManager'; import { Creative, LinearCreative, NonLinearCreative } from '../yospace/AdBreak'; export function stretchToParent(element: HTMLElement): void { diff --git a/yospace/src/utils/YospaceUtils.ts b/yospace/src/utils/YospaceUtils.ts index 65612da3..974bfd66 100644 --- a/yospace/src/utils/YospaceUtils.ts +++ b/yospace/src/utils/YospaceUtils.ts @@ -1,14 +1,17 @@ +import type { SourceDescription, TypedSource } from 'theoplayer'; import type { - SourceDescription, YospaceServerSideAdInsertionConfiguration, - YospaceSSAIIntegrationID, - YospaceTypedSource -} from 'theoplayer'; + YospaceSSAIIntegrationID +} from '../integration/YospaceConfiguration'; import { implementsInterface, isTypedSource, toSources } from './SourceUtils'; import { YospaceWindow } from '../yospace/YospaceWindow'; export const YOSPACE_SSAI_INTEGRATION_ID: YospaceSSAIIntegrationID = 'yospace'; +export interface YospaceTypedSource extends TypedSource { + ssai: YospaceServerSideAdInsertionConfiguration; +} + export function isYoSpaceServerSideAdInsertionConfiguration( ssai: any ): ssai is YospaceServerSideAdInsertionConfiguration {