Amazon Vinyl
    Preparing search index...

    Function getSegmentAtTime

    • Returns the segment whose range covers time (startTime <= time < endTime), or — when affordance > 0 — the next segment if time falls within affordance seconds before its startTime. Returns null if neither applies.

      Note: with affordance > 0, when time lies in the last affordance seconds of a segment that does cover it, the next segment is returned instead. This is deliberate — callers use affordance to absorb sub-second boundary differences across qualities — but it means the result is not strictly the segment containing time. Callers needing exact containment should pass affordance = 0.

      Type Parameters

      Parameters

      • time: number

        Lookup time, in seconds.

      • segments: readonly T[]

        Segments sorted by startTime ascending.

      • affordance: number = 0

        Forward-snap tolerance in seconds: if time falls just before a segment's startTime (within affordance), that segment is returned. The original time is still compared against endTime, so coverage never extends past it.

      Returns T | null