diff --git a/doc/api/Loading_a_Content.md b/doc/api/Loading_a_Content.md index eef8027f5f..cc44064f6f 100644 --- a/doc/api/Loading_a_Content.md +++ b/doc/api/Loading_a_Content.md @@ -191,13 +191,12 @@ either: - for VoD contents, it is the difference between the starting position and the end position of the content. -- **fromLivePosition** relative position relative to the content's live edge (for live - contents, it is the position that is intended to be broadcasted at the current time) if - it makes sense, in seconds. Should be a negative number. +- **fromLivePosition** position relative to the content's live edge (i.e. the position + that is intended to be broadcast at the current time) if it makes sense, in seconds. + Should be a negative number. If the live edge is unknown or if it does not make sense for the current content (for - example, it won't make sense for a VoD content), that setting repeats the same behavior - than **fromLastPosition**. + example, it won't make sense for VoD content), this setting is ignored. - **percentage** (`Number`): percentage of the wanted position. `0` being the minimum position possible (0 for static content, buffer depth for dynamic contents) and `100` diff --git a/src/main_thread/init/utils/get_initial_time.ts b/src/main_thread/init/utils/get_initial_time.ts index 2eacaf6afc..566c732eb1 100644 --- a/src/main_thread/init/utils/get_initial_time.ts +++ b/src/main_thread/init/utils/get_initial_time.ts @@ -93,6 +93,8 @@ export default function getInitialTime( if (!isNullOrUndefined(startAt)) { const min = getMinimumSafePosition(manifest); const max = getMaximumSafePosition(manifest); + const livePosition = getLivePosition(manifest); + if (!isNullOrUndefined(startAt.position)) { log.debug("Init: using startAt.minimumPosition"); return Math.max(Math.min(startAt.position, max), min); @@ -110,9 +112,12 @@ export default function getInitialTime( log.debug("Init: using startAt.fromLastPosition"); const { fromLastPosition } = startAt; return fromLastPosition >= 0 ? max : Math.max(min, max + fromLastPosition); - } else if (!isNullOrUndefined(startAt.fromLivePosition)) { + } else if ( + !isNullOrUndefined(startAt.fromLivePosition) && + livePosition !== undefined && + manifest.isLive + ) { log.debug("Init: using startAt.fromLivePosition"); - const livePosition = getLivePosition(manifest) ?? max; const { fromLivePosition } = startAt; return fromLivePosition >= 0 ? livePosition