Skip to content

Commit

Permalink
Add getLivePosition documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
peaBerberian committed Jan 24, 2024
1 parent fe46689 commit 2e0beb5
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 6 deletions.
4 changes: 4 additions & 0 deletions doc/api/Basic_Methods/.docConfig.json
Expand Up @@ -44,6 +44,10 @@
"path": "./getMaximumPosition.md",
"displayName": "getMaximumPosition"
},
{
"path": "./getLivePosition.md",
"displayName": "getLivePosition"
},
{
"path": "./getVideoDuration.md",
"displayName": "getVideoDuration"
Expand Down
44 changes: 44 additions & 0 deletions doc/api/Basic_Methods/getLivePosition.md
@@ -0,0 +1,44 @@
# getLivePosition

## Description

Returns the position in seconds in the current media corresponding to live
content.

Returns `null` if no content is currently loaded or if the current content is
not considered a live content.

Returns `undefined` if we cannot know the position corresponding to live
content currently.

Note that the live position is technically different than the maximum position
returned by [`getMaximumPosition`](./getMaximumPosition.md):

- `getMaximumPosition` returns the maximum position with content that may be
loaded. It may be further than the live position if future content is
already available (e.g. ad breaks already present in a Manifest) or may
be sooner if the live position is not yet available.

- `getLivePosition` just gives the information on the position which is
intended to correspond to the live content.

## Syntax

```js
const livePosition = player.getMaximumPosition();
```

- **return value** `number|null|undefined`: position for the live content, in
seconds.
`null` if no content is loaded or if the current loaded content is
not considered as a live content.
`undefined` if that live position is currently unknown.

## Example

```js
// playing 5 seconds before the live
player.seekTo({
position: player.getLivePosition() - 5,
});
```
11 changes: 8 additions & 3 deletions doc/api/Basic_Methods/getMaximumPosition.md
Expand Up @@ -2,12 +2,13 @@

## Description

Returns the maximum seekable player position.
Returns the maximum seekable player position in seconds on the current
loaded media.

Returns `null` if no content is currently loaded.

This is useful for live contents, where this position might be updated
continously as new content is generated.
This method allows thus to seek directly at the live edge of the content.

Please bear in mind that seeking exactly at the maximum position is rarely a
good idea:
Expand All @@ -18,6 +19,10 @@ good idea:

As such, we advise to remove a few seconds from that position when seeking.

Note that this is potentially different from the live position returned by
[`getLivePosition`](./getLivePosition.md), which is the method to call to know
which media position is intented to correspond to live content.

## Syntax

```js
Expand All @@ -30,7 +35,7 @@ const maximumPosition = player.getMaximumPosition();
## Example

```js
// seeking 5 seconds before the end (or the live edge for live contents)
// seeking 5 seconds before the last available position
player.seekTo({
position: player.getMaximumPosition() - 5,
});
Expand Down
6 changes: 3 additions & 3 deletions doc/reference/API_Reference.md
Expand Up @@ -276,6 +276,9 @@ properties, methods, events and so on.
- [`getMaximumPosition`](../api/Basic_Methods/getMaximumPosition.md): Get the
maximum seekable position.

- [`getLivePosition`](../api/Basic_Methods/getLivePosition.md): Get the
time corresponding to live content (when klaying live contents).

- [`getVideoDuration`](../api/Basic_Methods/getVideoDuration.md): Get the
duration linked to the media element.

Expand Down Expand Up @@ -469,9 +472,6 @@ properties, methods, events and so on.
- [`isPaused`](../api/Playback_Information/isPaused.md):
Returns `true` if the `<video>` element is paused.

- [`isContentLoaded`](../api/Playback_Information/isContentLoaded.md):
Returns `true` if a content is loaded.

- [`getLastStoredContentPosition`](../api/Playback_Information/getLastStoredContentPosition.md):
Returns the last stored content position, in seconds.

Expand Down

0 comments on commit 2e0beb5

Please sign in to comment.