mirror of
https://github.com/videojs/video.js.git
synced 2026-11-21 08:24:15 +01:00
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
3.9 KiB
3.9 KiB
@videojs/spf/features/calculate-duration
Source: src/playback/features/calculate-duration.ts
calculateDurationFeature
Calculates the presentation's duration from its selected tracks once they've loaded.
Requires a writer of resolved, selected video or audio tracks, such as videoFeature or audioFeature; without one,
no duration is set.
Behaviors
Config
Feature default is the value a feature's defaultConfig supplies. A behavior's own fallback for a key left unset is described under Doc.
| Key | Type | Feature default | Read by | Doc |
|---|---|---|---|---|
resolveDuration |
PresentationDurationResolver |
getResolvedSelectedTrackDuration |
calculatePresentationDuration | Resolver for presentation.duration. calculateDurationFeature supplies getResolvedSelectedTrackDuration, which picks the first resolved selected track's duration (video preferred, audio fallback). A resolver returning Number.POSITIVE_INFINITY marks the presentation live; downstream updateMediaSourceDuration propagates that value to mediaSource.duration per the MSE spec. |
State
| Key | Type | Initial | Declared by | Doc |
|---|---|---|---|---|
presentation |
MaybeResolvedPresentation | undefined |
— | calculatePresentationDuration | The presentation being played. A caller writes { url }; resolvePresentation parses the manifest and populates the rest. (documented on resolvePresentation) |
Composed by
- @videojs/spf/engines/hls-video
- @videojs/spf/engines/hls-audio
- @videojs/spf/engines/hls-background-video
- @videojs/spf/engines/hls-video-mpeg-ts
- @videojs/spf/engines/hls-audio-mpeg-ts
- @videojs/spf/engines/hls-background-video-mpeg-ts
Other functions and constants
| Name | Kind | Description | Source |
|---|---|---|---|
behaviors |
const | The behaviors the feature composes, in setup order. Listed under Behaviors. | src/playback/features/calculate-duration.ts |
defaultConfig |
const | The config defaults the feature contributes. Its value: { resolveDuration: getResolvedSelectedTrackDuration }. |
src/playback/features/calculate-duration.ts |
initialState |
const | The state values the feature seeds. It seeds none ({}). |
src/playback/features/calculate-duration.ts |
Types
| Name | Kind | Description | Source |
|---|---|---|---|
Behaviors |
type | The type of behaviors. |
src/playback/features/calculate-duration.ts |
Config |
type | Every config key the behaviors read. Listed under Config. | src/playback/features/calculate-duration.ts |
Context |
type | Every context key the behaviors declare. | src/playback/features/calculate-duration.ts |
State |
type | Every state key the behaviors and external signals declare. Listed under State. | src/playback/features/calculate-duration.ts |