Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FEC-13507): Doc entry methods #711

Merged
merged 10 commits into from
Jan 23, 2024
4 changes: 4 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2592,6 +2592,10 @@ Returns **[boolean][476]** true if sources contain youtube source

returns true if sources contain image source

## hasDocumentSource

returns true if sources contain document source

### Parameters

- `sources` **PKSourcesConfigObject** thr sources object
Expand Down
2 changes: 1 addition & 1 deletion src/common/playlist/playlist-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
SourcesConfig,
KPPlaylistItemConfigObject
} from '../../types';
const formats = ['hls', 'dash', 'progressive', 'image'];
const formats = ['hls', 'dash', 'progressive', 'image', 'document'];
/**
* @class PlaylistItem
* @param {PKSourcesConfigObject} [sources] - The item sources
Expand Down
15 changes: 14 additions & 1 deletion src/common/playlist/playlist-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ class PlaylistManager {
this._player = player;
this._eventManager = new EventManager();
this._playlist = new Playlist();
this._options = { autoContinue: true, loop: false, imageDuration: 5 };
this._options = {
autoContinue: true,
loop: false,
imageDuration: 5,
documentDuration: 5
};
this._countdown = { duration: 10, showing: true };
this._mediaInfoList = [];
this._playerOptions = options;
Expand Down Expand Up @@ -281,6 +286,8 @@ class PlaylistManager {
// @ts-ignore
items: playlistData.items.map((item, index) => {
const itemData = Utils.Object.copyDeep(item);
// keep original media source data
itemData.sources.mediaEntryType = item?.sources?.type;
['sources.dvr', 'sources.type'].forEach((omitKey) => {
// use medias source data instead of playlist source data
Utils.Object.deletePropertyPath(itemData, omitKey);
Expand Down Expand Up @@ -348,6 +355,12 @@ class PlaylistManager {
// @ts-ignore
sources: { duration: this._options.imageDuration }
});
} else if (this._player.isDocument()) {
this._player.configure({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
semarche-kaltura marked this conversation as resolved.
Show resolved Hide resolved
// @ts-ignore
sources: { duration: this._options.documentDuration }
});
}
}

Expand Down
16 changes: 16 additions & 0 deletions src/common/utils/setup-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,9 @@ function maybeSetStreamPriority(
if (sources && hasImageSource(sources)) {
return addEngineToStreamPriority(player, 'image', 'image');
}
if (sources && hasDocumentSource(sources)) {
return addEngineToStreamPriority(player, 'document', 'document');
}
return null;
}

Expand All @@ -914,6 +917,18 @@ function hasImageSource(sources: PKSourcesConfigObject): boolean {
return !!(source && source[0]);
}

/**
* returns true if sources contain document source
* @param {PKSourcesConfigObject} sources - thr sources object
* @returns {boolean} - true if sources contain document source
*/
function hasDocumentSource(sources: PKSourcesConfigObject): boolean {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const source = sources && sources.document;
return !!(source && source[0]);
}

/**
* Maybe set inBrowserFullscreen config based on the plugins.
* @private
Expand Down Expand Up @@ -1018,6 +1033,7 @@ export {
maybeSetStreamPriority,
hasYoutubeSource,
hasImageSource,
hasDocumentSource,
mergeProviderPluginsConfig,
getServerUIConf,
initializeStorageManagers,
Expand Down
25 changes: 22 additions & 3 deletions src/kaltura-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import { PlaylistManager } from './common/playlist/playlist-manager';
import { RemotePlayerManager } from './common/cast/remote-player-manager';
import {
hasImageSource,
hasDocumentSource,
hasYoutubeSource,
maybeSetStreamPriority,
mergeProviderPluginsConfig,
Expand Down Expand Up @@ -229,14 +230,18 @@ export class KalturaPlayer extends FakeEventTarget {
playerConfig.plugins[name] = playerConfig.plugins[name] || {};
});
this.configure({ session: mediaConfig.session });
if (!hasYoutubeSource(sources) && !hasImageSource(sources)) {
if (
hasYoutubeSource(sources) ||
hasImageSource(sources) ||
hasDocumentSource(sources)
) {
this._thumbnailManager = null;
} else {
this._thumbnailManager = new ThumbnailManager(
this,
this.config.ui,
mediaConfig
);
} else {
this._thumbnailManager = null;
}
this.updateKalturaPoster(
sources,
Expand Down Expand Up @@ -470,10 +475,24 @@ export class KalturaPlayer extends FakeEventTarget {
);
}

public isUntimedDocument(): boolean {
return (
hasDocumentSource(this.sources) &&
!(
typeof this.config.sources.duration === 'number' &&
this.config.sources.duration > 0
)
);
}

public isImage(): boolean {
return hasImageSource(this.sources);
}

public isDocument(): boolean {
return hasDocumentSource(this.sources);
}

public isAudio(): boolean {
return this._localPlayer.isAudio();
}
Expand Down
1 change: 1 addition & 0 deletions src/types/playlist/playlist-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export interface PlaylistOptions {
autoContinue: boolean;
loop: boolean;
imageDuration: number;
documentDuration: number;
}