AudioPlayer class for managing audio playback, track list and track information.

Hierarchy

  • AudioPlayer

Constructors

Properties

logger: {
    log: ((__namedParameters) => void);
}

Logger instance for the AudioPlayer class.

Uses: tslog

Type declaration

  • log: ((__namedParameters) => void)
      • (__namedParameters): void
      • Parameters

        • __namedParameters: {
              fn: string;
              message: string;
          }
          • fn: string

            The function that is logging

          • message: string

            The log message

        Returns void

onTrackEndCallback: (() => void)

Type declaration

    • (): void
    • Callback function triggered when a track ends.

      Returns void

selectedTrack: null | AudioTrack

Currently selected audio track.

trackList: AudioTrack[]

List of audio tracks managed by the player.

Methods

  • Adds multiple tracks to the track list.

    Parameters

    • tracks: NewTrackDetails[]

      An array of track details to be added.

    • options: {
          selectTrack: boolean;
      } = ...

      Additional options for track addition.

      • selectTrack: boolean

        Set to true to select the first added track, false by default.

    Returns void

    Remarks

    This function adds multiple tracks to the track list and optionally selects one of them as the currently playing track.

  • Retrieves the duration of the currently selected track asynchronously.

    Returns Promise<number>

    A promise that resolves with the duration of the track (in seconds).

    Throws

    If no track is loaded.

  • Retrieves a copy of the track list without the 'howl' property.

    Returns {
        artists: Artist[];
        artwork: Artwork;
        id: string;
        label: string;
        productUrl: string;
        title: string;
        url: string;
    }[]

    A copy of the track list.

  • Seeks to a specified timestamp in the currently selected track.

    Parameters

    • timestamp: number

      The timestamp to seek to in seconds.

    Returns null | number

    The updated playback position or null if seeking failed.

Generated using TypeDoc