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: 12 additions & 3 deletions src/common/playlist/playlist-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@
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 @@
// @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 @@ -344,10 +351,12 @@
private _onChangeSourceStarted(): void {
if (this._player.isImage()) {
this._player.configure({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
sources: { duration: this._options.imageDuration }

Check failure on line 354 in src/common/playlist/playlist-manager.ts

View workflow job for this annotation

GitHub Actions / type-check / running-tests (ubuntu-latest)

Type '{ duration: number; }' is missing the following properties from type 'PKSourcesConfigObject': hls, dash, progressive, image, and 4 more.

Check failure on line 354 in src/common/playlist/playlist-manager.ts

View workflow job for this annotation

GitHub Actions / build-types / running-tests (ubuntu-latest)

Type '{ duration: number; }' is missing the following properties from type 'PKSourcesConfigObject': hls, dash, progressive, image, and 4 more.

Check failure on line 354 in src/common/playlist/playlist-manager.ts

View workflow job for this annotation

GitHub Actions / build / running-tests (ubuntu-latest)

Type '{ duration: number; }' is missing the following properties from type 'PKSourcesConfigObject': hls, dash, progressive, image, and 4 more.
});
} else if (this._player.isDocument()) {
this._player.configure({
sources: { duration: this._options.documentDuration }

Check failure on line 358 in src/common/playlist/playlist-manager.ts

View workflow job for this annotation

GitHub Actions / type-check / running-tests (ubuntu-latest)

Type '{ duration: number; }' is missing the following properties from type 'PKSourcesConfigObject': hls, dash, progressive, image, and 4 more.

Check failure on line 358 in src/common/playlist/playlist-manager.ts

View workflow job for this annotation

GitHub Actions / build-types / running-tests (ubuntu-latest)

Type '{ duration: number; }' is missing the following properties from type 'PKSourcesConfigObject': hls, dash, progressive, image, and 4 more.

Check failure on line 358 in src/common/playlist/playlist-manager.ts

View workflow job for this annotation

GitHub Actions / build / running-tests (ubuntu-latest)

Type '{ duration: number; }' is missing the following properties from type 'PKSourcesConfigObject': hls, dash, progressive, image, and 4 more.
});
}
}

Expand Down
14 changes: 14 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 @@
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,16 @@
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 {
const source = sources && sources.document;

Check failure on line 926 in src/common/utils/setup-helpers.ts

View workflow job for this annotation

GitHub Actions / type-check / running-tests (ubuntu-latest)

Property 'document' does not exist on type 'PKSourcesConfigObject'.

Check failure on line 926 in src/common/utils/setup-helpers.ts

View workflow job for this annotation

GitHub Actions / build-types / running-tests (ubuntu-latest)

Property 'document' does not exist on type 'PKSourcesConfigObject'.

Check failure on line 926 in src/common/utils/setup-helpers.ts

View workflow job for this annotation

GitHub Actions / build / running-tests (ubuntu-latest)

Property 'document' does not exist on type 'PKSourcesConfigObject'.
return !!(source && source[0]);
}

/**
* Maybe set inBrowserFullscreen config based on the plugins.
* @private
Expand Down Expand Up @@ -1018,6 +1031,7 @@
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;
}
Loading