Amazon Vinyl
    Preparing search index...

    Interface SegmentController

    Provides segments for a given time. Handles segment prefetching and caching.

    interface SegmentController {
        error: Error | null;
        fetchedRanges: ReadonlyRanges;
        streamingQuality: MediaQualityMetadata | null;
        activate(): void;
        clear(): void;
        configure(options: Partial<PrefetchOptions>): void;
        deactivate(): void;
        dispose(): void;
        getSegment(
            time: number,
            abort?: ReadonlyAbort,
        ): Promise<SegmentReference<ArrayBuffer> | null>;
        hasAnyListeners(): boolean;
        hasListeners(type: keyof SegmentControllerEventMap): boolean;
        on<K extends keyof SegmentControllerEventMap>(
            type: K,
            handler: EventHandler<SegmentControllerEventMap[K]>,
            options?: SignalOptions,
        ): Unsubscribe;
        reset(): void;
    }

    Hierarchy (View Summary)

    Implemented by

    Index
    error: Error | null
    fetchedRanges: ReadonlyRanges

    The time ranges currently fetched.

    streamingQuality: MediaQualityMetadata | null

    The most recently requested quality metadata.

    • Returns a Promise for a segment covering the given time, with quality chosen by the configured QualitySelector. Resolves to null if no media exists at that time. Negative time values are clamped to 0.

      The lookup forward-snaps by SEGMENT_START_AFFORDANCE: if time falls within that window before a segment's startTime, that segment is returned. This absorbs sub-second segment-boundary differences across qualities so an ABR switch doesn't replay or skip media at the boundary.

      Calling this also blocks the prefetch queue until the returned promise settles, so the active request is prioritized over background prefetching.

      Parameters

      • time: number

        The time, in seconds, the requested segment should span.

      • Optionalabort: ReadonlyAbort

        Aborts the returned promise (rejecting with AbortError) and releases the prefetch-queue lock. The underlying network request may continue so its result can still populate the cache.

      Returns Promise<SegmentReference<ArrayBuffer> | null>