Files
video.js-mirror/packages/spf/docs/reference/features/calculate-duration.md

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

  1. calculatePresentationDuration

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

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