Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Index

Constructors

constructor

  • new HlsService(master: HTMLVideoElement, eventCallback: <T>(event: T) => void, internalEventBus: EventMixin, settings: HlsPlayerSettings): HlsService
  • Note Should only be used from within the player.

    Parameters

    • master: HTMLVideoElement

      The video element.

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

      Callback to control internal event handling.

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

          • T: PlayerEvent

          Parameters

          • event: T

          Returns void

    • internalEventBus: EventMixin

      Event bus for internal communication.

    • settings: HlsPlayerSettings

      Basic settings controlling the behavior.

    Returns HlsService

Properties

playbackRates

playbackRates: number[] = ...

plugin

plugin: PluginApi

An object containing all currently registered plugins. Access a specific plugin using the Plugins static property Name, i.e. plugin[Plugin.Name].

Accessors

hlsPlayer

  • 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

isLooping

  • get isLooping(): boolean
  • Returns boolean

isSeeking

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

    Returns boolean

loaded

  • get loaded(): boolean
  • Player and plugins, if any, are ready for continued playback.

    Returns boolean

master

  • get master(): HTMLMediaElement
  • Returns HTMLMediaElement

maximumPlaybackRate

  • get maximumPlaybackRate(): number
  • The maximum acceptable value for playback rate.

    Returns number

    The maximum value.

minimumPlaybackRate

  • get minimumPlaybackRate(): number
  • The minimum acceptable value for playback rate.

    Returns number

    The minimum value.

muted

  • get muted(): boolean
  • Player and plugins, if any, are all muted.

    Returns boolean

playbackRateIncrements

  • get playbackRateIncrements(): number[]
  • Returns a list of playback rates that are used when increasing or decreasing playback rate.

    Returns number[]

Methods

abrEnabled

  • abrEnabled(): boolean
  • Returns boolean

cancelLoop

  • cancelLoop(): void
  • Cancels loop playback.

    Returns void

decreasePlaybackRate

  • decreasePlaybackRate(): void
  • Decreases the current playback rate based on predefined steps.

    Returns void

destroy

  • destroy(): Promise<void>
  • Destroys the service, should only be called from within the player.

    Returns Promise<void>

getActiveAudioIndex

  • getActiveAudioIndex(): number
  • Returns the id of the active audio track.

    Returns number

getActiveFile

  • getActiveFile(): VideoFile
  • Returns the active video file or undefined if no video file is loaded.

    Returns VideoFile

getActiveSubtitleIndex

  • getActiveSubtitleIndex(): number
  • Returns the id of the active subtitle track.

    Returns number

getActiveVideoRepresentationIndex

  • getActiveVideoRepresentationIndex(): number
  • Returns the index of the active video representation, or -1 if set to auto.

    Returns number

getAudioTracks

  • Returns the audio tracks of the current HLS file.

    Returns HlsAudioTrack[]

getCurrentTime

  • getCurrentTime(format?: TimeFormat): string | number
  • Returns the current time of the player in the requested format.

    Parameters

    • Optional format: TimeFormat

      The format to return the current time in.

    Returns string | number

getDuration

  • getDuration(format?: TimeFormat): string | number
  • Returns the duration of the current media in the requested format.

    Parameters

    • Optional format: TimeFormat

      The format to return the duration in.

    Returns string | number

getStatus

  • getStatus(): PlayerStatus
  • Returns the current status of the active media.

    Returns PlayerStatus

getSubtitles

  • Returns the subtitle tracks of the current HLS file.

    Returns HlsSubtitleTrack[]

getVideoRepresentations

  • getVideoRepresentations(): VideoRepresentation[]
  • Returns all available video representations for the stream sorted by bandwidth (lowest bandwidth at index 0).

    Returns VideoRepresentation[]

increasePlaybackRate

  • increasePlaybackRate(): void
  • Increases the current playback rate based on predefined steps.

    Returns void

listPlugins

  • listPlugins(): Plugin[]
  • Returns a list of all registered plugins.

    Returns Plugin[]

loadVideoFile

  • loadVideoFile(videoFile: VideoFile): void
  • Load a specific video file.

    Parameters

    • videoFile: VideoFile

      The video file to load.

    Returns void

loop

  • loop(inFrame: number, outFrame: number): void
  • Loop section of loaded Video.

    Parameters

    • inFrame: number

      inclusive

    • outFrame: number

      exclusive

    Returns void

mute

  • mute(): void
  • Mutes the player.

    Returns void

muteMuxed

  • muteMuxed(): void
  • Mutes the muxed audio

    Returns void

onPlayerStatusChanged

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

    Returns void

pause

  • pause(pauseOn?: SeekEvent, userPause?: boolean): Promise<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>

play

  • play(): Promise<void>
  • Starts playback. Queues requests if the player is seeking or loading to achieve autoplay behavior.

    Returns Promise<void>

seek

  • seek(event: SeekEvent, roundingMode?: RoundingMode): 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

    Returns Promise<void>

setAudioTrack

  • setAudioTrack(index: number): void
  • Activate a audio track.

    Parameters

    • index: number

      The id of the audio track to activate.

    Returns void

setFrameOffset

  • setFrameOffset(offset: number): 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

setPlaybackRate

  • setPlaybackRate(rate: number): number
  • Sets the playback rate. Limited to predefined min- and max values.

    Parameters

    • rate: number

      The new playback rate

    Returns number

setSubtitleTrack

  • setSubtitleTrack(index: number): 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

setVideoRepresentation

  • setVideoRepresentation(index: number): void
  • Set the desired video representation using id. -1 will enable auto switch.

    Parameters

    • index: number

      The index of the desired representation.

    Returns void

setVolume

  • setVolume(volume: number): void
  • Set the volume of the player.

    Parameters

    • volume: number

      A number between 0 and 1.

    Returns void

setVolumeController

  • setVolumeController(volumeController: VolumeController): void
  • Sets the default controller for the volume

    Parameters

    • volumeController: VolumeController

      the volume controller

    Returns void

toggleMute

  • toggleMute(): void
  • Toggles mute.

    Returns void

toggleMuteMuxed

  • toggleMuteMuxed(): void
  • Toggles mute on the muxed audio

    Returns void

togglePlay

  • togglePlay(): Promise<void>
  • Toggles playback.

    Returns Promise<void>

unmute

  • unmute(): void
  • Unmutes the player.

    Returns void

unmuteMuxed

  • unmuteMuxed(): void
  • Unmutes the muxed audio

    Returns void

updateVideoFile

  • updateVideoFile(videoFile: VideoFile): void
  • Parameters

    • videoFile: VideoFile

    Returns void

useDropFrame

  • useDropFrame(dropFrame: boolean): 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