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

## hasDocSource

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', 'doc'];
/**
* @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,
docDuration: 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.isDoc()) {
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.docDuration }
});
}
}

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 && hasDocSource(sources)) {
return addEngineToStreamPriority(player, 'doc', 'doc');
}
return null;
}

Expand All @@ -914,6 +917,16 @@
return !!(source && source[0]);
}

/**
* returns true if sources contain doc source
* @param {PKSourcesConfigObject} sources - thr sources object
* @returns {boolean} - true if sources contain doc source
*/
function hasDocSource(sources: PKSourcesConfigObject): boolean {
const source = sources && sources.doc;

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 'doc' 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 'doc' 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 / type-check / running-tests (ubuntu-latest)

Property 'doc' 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,
hasDocSource,
mergeProviderPluginsConfig,
getServerUIConf,
initializeStorageManagers,
Expand Down
21 changes: 20 additions & 1 deletion 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,
hasDocSource,
hasYoutubeSource,
maybeSetStreamPriority,
mergeProviderPluginsConfig,
Expand Down Expand Up @@ -229,7 +230,11 @@ export class KalturaPlayer extends FakeEventTarget {
playerConfig.plugins[name] = playerConfig.plugins[name] || {};
});
this.configure({ session: mediaConfig.session });
if (!hasYoutubeSource(sources) && !hasImageSource(sources)) {
if (
!hasYoutubeSource(sources) &&
semarche-kaltura marked this conversation as resolved.
Show resolved Hide resolved
!hasImageSource(sources) &&
!hasDocSource(sources)
) {
this._thumbnailManager = new ThumbnailManager(
this,
this.config.ui,
Expand Down Expand Up @@ -470,10 +475,24 @@ export class KalturaPlayer extends FakeEventTarget {
);
}

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

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

public isDoc(): boolean {
return hasDocSource(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;
docDuration: number;
}
Loading