videoflix-frontend - v0.0.0
    Preparing search index...

    Centralized state and behavior for video playback across the app.

    Responsibilities:

    • Holds the currently active video (if any) and its playback position.
    • Persists and restores playback progress from localStorage.
    • Resolves a signed S3 URL for the active video based on the selected quality.
    • Prevents duplicate signed-URL requests via an internal deduplication key.

    Compatibility:

    • Existing consumers (video item pages/components) continue to work unchanged.
    • Header component can opt into "start from 0:00" by calling beginFromStart(video).
    Index

    Constructors

    Properties

    currentTime: WritableSignal<number> = ...

    Current playback time (in seconds).

    defaultSource: WritableSignal<string> = ...

    The currently resolved signed URL for the active video.

    startSavedTime: WritableSignal<boolean> = ...

    Whether to resume from a saved time (true) or start from 0:00 (false) for the current video session.

    video: WritableSignal<Video | null> = ...

    Currently active video (or null if none).

    videoQualityService: VideoQualityService = ...

    Quality manager (network-adaptive and manual switching).

    Methods

    • Begin playback for a given video from the very beginning (0:00). This disables resume for the current session and forces a fresh URL fetch.

      Use-case:

      • Header component wants a "clean start" independent of the teaser's time.

      Parameters

      • v: Video

        The video to start.

      Returns void

    • Load a persisted playback position from localStorage for a given video ID. Sets both currentTime and startSavedTime (true if a saved time exists).

      Parameters

      • videoId: number

        The video identifier.

      Returns void

    • Reset all runtime state so the next playback session starts clean. Safe for reuse across the app; does not affect other components unless called.

      Returns void

    • Persist the current playback position to localStorage for a given video ID. Uses a deterministic key: videoProgress_<id>.

      Parameters

      • videoId: number

        The video identifier.

      Returns void

    • Switch the target quality by index (0..3). Mapping: 0 → 120p, 1 → 360p, 2 → 720p, 3 → 1080p.

      Parameters

      • index: number

        Quality index (clamped to 0..3).

      Returns void

    • Update the current playback time (usually bound to timeupdate).

      Parameters

      • time: number

        Current playback position in seconds.

      Returns void