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) handle doc entry #721

Merged
merged 13 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ yarn-error.log
LICENSE
README.md
ts-typed/
webpack.config.js
tsconfig.json

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
@@ -1,6 +1,6 @@
import { Utils } from '@playkit-js/playkit-js';
import { PluginsConfig, 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 @@ -32,7 +32,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 @@ -245,6 +250,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 @@ -291,6 +298,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
// @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 @@ -706,6 +706,9 @@ function maybeSetStreamPriority(player: KalturaPlayer, sources: PKSourcesConfigO
if (sources && hasImageSource(sources)) {
return addEngineToStreamPriority(player, 'image', 'image');
}
if (sources && hasDocumentSource(sources)) {
return addEngineToStreamPriority(player, 'document', 'document');
}
return null;
}

Expand All @@ -731,6 +734,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 @@ -818,6 +833,7 @@ export {
maybeSetStreamPriority,
hasYoutubeSource,
hasImageSource,
hasDocumentSource,
mergeProviderPluginsConfig,
getServerUIConf,
initializeStorageManagers,
Expand Down
15 changes: 12 additions & 3 deletions src/kaltura-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,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 @@ -191,10 +192,10 @@ export class KalturaPlayer extends FakeEventTarget {
playerConfig.plugins[name] = playerConfig.plugins[name] || {};
});
this.configure({ session: mediaConfig.session });
if (!hasYoutubeSource(sources) && !hasImageSource(sources)) {
this._thumbnailManager = new ThumbnailManager(this, this.config.ui, mediaConfig);
} else {
if (hasYoutubeSource(sources) || hasImageSource(sources) || hasDocumentSource(sources)) {
this._thumbnailManager = null;
} else {
this._thumbnailManager = new ThumbnailManager(this, this.config.ui, mediaConfig);
}
this.updateKalturaPoster(sources, mediaConfig.sources, this._localPlayer.dimensions);
addKalturaParams(this, { ...playerConfig, sources });
Expand Down Expand Up @@ -383,10 +384,18 @@ export class KalturaPlayer extends FakeEventTarget {
return hasImageSource(this.sources) && !(typeof this.config.sources.duration === 'number' && this.config.sources.duration > 0);
}

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;
}
Loading