Vinyl
    Preparing search index...

    Interface PlaybackController

    interface PlaybackController {
        buffered: ReadonlyRanges;
        canPlay: boolean;
        canPlayThrough: boolean;
        currentTime: number;
        currentTimePercent: number;
        defaultPlaybackRate: number;
        duration: number;
        ended: boolean;
        error: null | Error;
        hasMetadata: boolean;
        loop: boolean;
        muted: boolean;
        networkState: PlaybackNetworkState;
        paused: boolean;
        playbackRate: number;
        playing: boolean;
        playIsPending: boolean;
        preservesPitch: boolean;
        readyState: PlaybackReadyState;
        seekable: ReadonlyRanges;
        seeking: boolean;
        volume: number;
        waiting: boolean;
        hasAnyListeners(): boolean;
        hasListeners(type: keyof PlaybackControllerEventMap): boolean;
        on<K extends keyof PlaybackControllerEventMap>(
            type: K,
            handler: EventHandler<PlaybackControllerEventMap[K]>,
            options?: SignalOptions,
        ): Unsubscribe;
        pause(): void;
        play(): Promise<void>;
        reset(): void;
        seekTo(time: number, tolerance?: number): Promise<void>;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    buffered: ReadonlyRanges

    Returns a new static normalized ReadonlyRanges object that represents the ranges of the media resource, if any, that the user agent has buffered at the moment the buffered property is accessed.

    Note: ReadonlyRanges is a view to the DOM TimeRanges object.

    canPlay: boolean

    True if the readyState is PlaybackReadyState.HAVE_FUTURE_DATA This will be true after a PlaybackControllerEventMap.canPlay event.

    Note that security permissions may not allow a track to load past metadata before there has been a user interaction. This should not be relied upon before invoking PlaybackController.play.

    canPlayThrough: boolean

    True if the readyState is PlaybackReadyState.HAVE_ENOUGH_DATA This will be true after a PlaybackControllerEventMap.canPlayThrough event.

    Note that security permissions may not allow a track to load past metadata before there has been a user interaction. This should not be relied upon before invoking PlaybackController.play.

    currentTime: number

    The current playback time in seconds. When changed, a 'timeUpdate' event is emitted.

    currentTimePercent: number

    Returns current time as a percent of the total duration.

    A number between 0-1

    defaultPlaybackRate: number

    The default playback rate when the user is not using fast forward or reverse for a video or audio resource.

    duration: number

    The length of the element's media in seconds. Observe changes with durationChange events.

    ended: boolean

    Indicates whether the media element has ended playback.

    error: null | Error

    The Error object for the most recent error, or null if there has not been an error. When an error event is received by the element, you can determine details about what happened by examining this object.

    hasMetadata: boolean

    True if the readyState is at least PlaybackReadyState.HAVE_METADATA

    This will be true after a PlaybackControllerEventMap.loadedMetadata event and false after an PlaybackControllerEventMap.emptied event.

    loop: boolean

    Controls whether the media element should start over when it reaches the end.

    muted: boolean

    Indicates whether the media element muted. Observe changes with mutedChange events.

    networkState: PlaybackNetworkState

    Indicates the current state of the fetching of media over the network.

    paused: boolean

    Indicates whether the media element is paused. Observe changes with play and pause events.

    playbackRate: number

    Sets the rate at which the media is being played back. This is used to implement user controls for fast-forward, slow motion, and so forth. The normal playback rate is multiplied by this value to obtain the current rate, so a value of 1.0 indicates normal speed.

    playing: boolean

    True if playback has started, is not paused, stalled, or seeking. Observe changes with 'playing' and 'played' events.

    playIsPending: boolean

    True if play has been called and the returned promise is currently in a pending state. Observe changes with PlaybackControllerEventMap.playIsPendingChange events.

    preservesPitch: boolean

    Determines whether the browser should adjust the pitch of the audio to compensate for changes to the playback rate. Default: true

    readyState: PlaybackReadyState

    Indicates the readiness state of the media. Observe changes with PlaybackControllerEventMap.readyStateChange events.

    seekable: ReadonlyRanges

    Returns a new static normalized ReadonlyRanges object that represents the ranges of the media resource, if any, that the user agent is able to seek to at the time seekable property is accessed.

    Note: ReadonlyRanges is a view to the DOM TimeRanges object.

    seeking: boolean

    True if the element is currently seeking. Observe changes with seeking and seeked events.

    volume: number

    The volume level for audio portions of the media element. Observe changes with volumeChange events.

    waiting: boolean

    True if playback is stopped due to waiting for data. Observe changes with waiting and waited events.

    Methods

    • Returns true if the event host has any listeners.

      Returns boolean

    • Pauses playback of the media, if the media is already in a paused state this method will have no effect. If a play is pending, the play will be aborted and the promise returned by play() will be rejected.

      Returns void

      • pendingPlay
      • play
    • Attempts to begin playback of the media. It returns a Promise which is resolved when playback has been successfully started.

      Failure to begin playback for any reason, such as permission issues or interruption via pause, results in the promise being rejected.

      The first time play() is invoked, except muted video, should be in response to a user interaction such as a button click.

      Returns Promise<void>

      isNotAllowedError

    • Resets the error state.

      Returns void

    • Safely seeks to the given time. The seek will begin only after readyState is at least PlaybackReadyState.HAVE_METADATA. If a previous seek was still pending, the previous seek will be ignored. Returns a Promise that resolves when the seek has completed. If the seek is interrupted by another seek, the promise will be rejected with an AbortError. If the seek is not to a seekable range, the promise will reject with an InvalidSeekError.

      Parameters

      • time: number

        The value, in seconds, to set the playback time.

      • Optionaltolerance: number

        The amount of tolerance to have when the time is outside the seekable ranges to snap, in seconds. If time is outside all seekable ranges beyond this tolerance, the seek will be ignored. Default: 0.5

      Returns Promise<void>