This service is a api layer that handles the communication with the video element regarding playback. It provides information about the currently loaded HLS file such as subtitles and audio tracks.

Note This service is created by the HlsPlayer on startup and should never be instantiated elsewhere.

Hierarchy

  • Service
    • HlsService

Constructors

  • Note Should only be used from within the player.

    Parameters

    • master: HTMLVideoElement

      The video element.

    • eventCallback: (<T>(event) => void)

      Callback to control internal event handling.

        • <T>(event): void
        • Type Parameters

          • T extends PlayerEvent

          Parameters

          • event: T

          Returns void

    • internalEventBus: EventMixin

      Event bus for internal communication.

    • settings: HlsPlayerSettings

      Basic settings controlling the behavior.

    Returns HlsService

Properties

plugin: PluginApi

An object containing all currently registered plugins. Access a specific plugin using the Plugins static property Name.

Example

const hotkeyPlugin = player.api.plugin[HotkeyPlugin.Name];

Accessors

  • get ended(): boolean
  • Returns true if the video playback has ended, false otherwise

    Returns boolean

  • get hlsPlayer(): Hls
  • Returns the current instance of the hls.js player. It's recommended to use this as little as possible to achieve a consistent behavior.

    Returns Hls

  • get isSeeking(): boolean
  • Returns true if a seek is in progress, false otherwise

    Returns boolean

  • get master(): HTMLMediaElement
  • The video element used for playback.

    Returns HTMLMediaElement

Methods

  • Returns boolean

  • Destroys the service, should only be called from within the player.

    Returns Promise<void>

  • Returns the id of the active audio track.

    Returns number

  • Returns the active video file or undefined if no video file is loaded.

    Returns VideoFile

  • Returns the id of the active subtitle track.

    Returns number

  • Returns the index of the active video representation, or -1 if set to auto.

    Returns number

  • Returns the current time of the player in the requested format.

    Parameters

    • format: Frame

      The format to return the current time in.

    Returns number

  • Parameters

    • format: Milliseconds

    Returns number

  • Parameters

    • format: Percent

    Returns number

  • Parameters

    • format: Seconds

    Returns number

  • Parameters

    • format: Timecode

    Returns string

  • Parameters

    • format: Time

    Returns string

  • Parameters

    • format: TimeFormat

    Returns string | number

  • Returns number

  • Returns the duration of the current media in the requested format.

    Parameters

    • format: Frame

      The format to return the duration in.

    Returns number

  • Parameters

    • format: Milliseconds

    Returns number

  • Parameters

    • format: Percent

    Returns number

  • Parameters

    • format: Seconds

    Returns number

  • Parameters

    • format: Time

    Returns string

  • Parameters

    • format: Timecode

    Returns string

  • Parameters

    • format: TimeFormat

    Returns string | number

  • Returns number

  • Returns the current status of the active media.

    Returns PlayerStatus

  • Returns all available video representations for the stream sorted by bandwidth (lowest bandwidth at index 0).

    Returns VideoRepresentation[]

  • Helper method to make sure that playback is resumed correctly. Should only be used from within the player.

    Returns void

  • Pauses playback and makes sure that the player is stopped at an exact frame.

    Parameters

    • Optional pauseOn: SeekEvent

      (Optional) Seek to specific time when pausing.

    • Optional userPause: boolean

    Returns Promise<void>

  • Starts playback. Queues requests if the player is seeking or loading to achieve autoplay behavior.

    Returns Promise<void>

  • Seeks to a specific time in the current media.

    Parameters

    • event: SeekEvent

      Specifies where to seek to within the media.

    • Optional roundingMode: RoundingMode
    • Optional userSeek: boolean

    Returns Promise<void>

  • Activate a audio track.

    Parameters

    • index: number

      The id of the audio track to activate.

    Returns void

  • Update frameOffset value for all loaded videoFiles. Equivalent to load videoFile with a specific frameOffset.

    Parameters

    • offset: number

      Frame offset to set.

    Returns void

  • Activate a subtitle track.

    Parameters

    • index: number

      The id of the subtitle track to activate, or -1 if all subtitles should be deactivated.

    Returns void

  • Set the desired video representation using id. -1 will enable auto switch.

    Parameters

    • index: number

      The index of the desired representation.

    Returns void

  • Set the volume of the player.

    Parameters

    • volume: number

      A number between 0 and 1.

    Returns void

  • Sets the default controller for the volume

    Parameters

    • volumeController: VolumeController

      the volume controller

    Returns void

  • Toggles playback.

    Returns Promise<void>

  • Parameters

    • videoFile: VideoFile

    Returns void

  • Update the dropFrame value for all loaded videoFiles. Equivalent to load videoFile with dropFrame property set.

    Parameters

    • dropFrame: boolean

      Drop frame value to set.

    Returns void