Skip to content

Commit

Permalink
Merge pull request #37 from THEOplayer/yospace-configuration-type
Browse files Browse the repository at this point in the history
Add Yospace configuration types to connector
  • Loading branch information
MattiasBuelens authored Jul 31, 2024
2 parents 1051252 + 898b3e4 commit c7660f9
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changeset/khaki-clocks-flow.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions yospace/src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
32 changes: 32 additions & 0 deletions yospace/src/integration/YospaceConfiguration.ts
Original file line number Diff line number Diff line change
@@ -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;
}
8 changes: 6 additions & 2 deletions yospace/src/integration/YospaceConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ export class YospaceConnector implements EventDispatcher<YospaceEventMap> {
*
* 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.
*/
Expand Down
1 change: 0 additions & 1 deletion yospace/src/integration/YospaceUIHandler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { YospaceSessionManager } from '../yospace/YospaceSessionManager';
import { Creative, LinearCreative, NonLinearCreative } from '../yospace/AdBreak';

export function stretchToParent(element: HTMLElement): void {
Expand Down
11 changes: 7 additions & 4 deletions yospace/src/utils/YospaceUtils.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit c7660f9

Please sign in to comment.