Skip to content

Commit

Permalink
feat(FEC-13461): handle clip video query params (#671)
Browse files Browse the repository at this point in the history
### Description of the Changes

handles `seekFrom` and `clipTo` url query parameters, for clipping the video (changing the duration).

Solves FEC-13461
  • Loading branch information
lianbenjamin authored Dec 3, 2023
1 parent a230281 commit 209ab00
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/common/utils/setup-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const setupMessages: Array<Object> = [];
const CONTAINER_CLASS_NAME: string = 'kaltura-player-container';
const KALTURA_PLAYER_DEBUG_QS: string = 'debugKalturaPlayer';
const KALTURA_PLAYER_START_TIME_QS: string = 'kalturaStartTime';
const KALTURA_PLAYER_CLIP_START_TIME_QS: string = 'kalturaSeekFrom';
const KALTURA_PLAYER_CLIP_END_TIME_QS: string = 'kalturaClipTo';
const KAVA_DEFAULT_PARTNER = 2504201;
const KAVA_DEFAULT_IMPRESSION = `https://analytics.kaltura.com/api_v3/index.php?service=analytics&action=trackEvent&apiVersion=3.3.0&format=1&eventType=1&partnerId=${KAVA_DEFAULT_PARTNER}&entryId=1_3bwzbc9o&&eventIndex=1&position=0`;
Expand Down Expand Up @@ -214,6 +216,23 @@ function maybeApplyStartTimeQueryParam(options: KPOptionsObject): void {
}
}
/**
* get the parameters for seekFrom and clipTo
* @private
* @param {KPOptionsObject} options - kaltura player options
* @returns {void}
*/
function maybeApplyClipQueryParams(options: KPOptionsObject): void {
const seekFrom = parseFloat(getUrlParameter(KALTURA_PLAYER_CLIP_START_TIME_QS));
if (!isNaN(seekFrom)) {
Utils.Object.createPropertyPath(options, 'sources.seekFrom', seekFrom);
}
const clipTo = parseFloat(getUrlParameter(KALTURA_PLAYER_CLIP_END_TIME_QS));
if (!isNaN(clipTo)) {
Utils.Object.createPropertyPath(options, 'sources.clipTo', clipTo);
}
}
/**
* set the logger
* @private
Expand Down Expand Up @@ -759,6 +778,7 @@ export {
validateProviderConfig,
setLogOptions,
maybeApplyStartTimeQueryParam,
maybeApplyClipQueryParams,
createKalturaPlayerContainer,
checkNativeHlsSupport,
getDefaultOptions,
Expand Down
2 changes: 2 additions & 0 deletions src/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
attachToFirstClick,
getDefaultOptions,
maybeApplyStartTimeQueryParam,
maybeApplyClipQueryParams,
printKalturaPlayerVersionToLog,
printSetupMessages,
setLogOptions,
Expand All @@ -31,6 +32,7 @@ function setup(options: PartialKPOptionsObject | LegacyPartialKPOptionsObject):
validateProviderConfig(defaultOptions);
setLogOptions(defaultOptions);
maybeApplyStartTimeQueryParam(defaultOptions);
maybeApplyClipQueryParams(defaultOptions);
printSetupMessages();
setStorageConfig(defaultOptions);
const player = getPlayerProxy(defaultOptions);
Expand Down

0 comments on commit 209ab00

Please sign in to comment.