Options
All
  • Public
  • Public/Protected
  • All
Menu

This plugin enables synchronized playback of multiple discrete audio tracks, synchronized against the video.

How to use

const player = new ProgressivePlayer(...);
const dap = new DiscreteAudioPlugin(player);

// Add audio tracks
// Note. if ChannelControlPlugin is to be used, channelCount of each track must be set.
dap.initDiscreteAudioTracks(listOfTracks)

// Enable track
dap.enableTrack(trackSrc)

Once a track is enabled it will be kept synchronized against the video.

Limitations

Browsers have a limit for simultaneous downloads from a single domain. It is not possible to play more than, dependent on browser, 5 discrete audio tracks at the same time (more about the browser limitation here

Hierarchy

Index

Constructors

constructor

  • This class is responsible of keeping multiple Playables in sync with regard to currentTime, buffering etc.

    Parameters

    • player: Player

      The player to add this plugin to.

    • Optional settings: Partial<DiscreteAudioSettings>

      Settings that configure how the plugin should behave, some values default to player values if unset.

    Returns DiscreteAudioPlugin

Properties

Readonly name

name: string

Static Name

Name: string = ...

Accessors

audioTracks

  • Returns all registered internal audio tracks as the external representation.

    Returns DiscreteAudioTrack[]

    An array of audio tracks.

loaded

  • get loaded(): boolean
  • set loaded(loaded: boolean): void
  • Property that states whether this plugin considers itself ready for continued playback based on internal logic. Triggers internal event of type PlayerInternalEventType.LoadedChanged if property value was changed.

    Returns boolean

  • Property that states whether this plugin considers itself ready for continued playback based on internal logic. Triggers internal event of type PlayerInternalEventType.LoadedChanged if property value was changed.

    Parameters

    • loaded: boolean

    Returns void

muted

  • get muted(): boolean
  • set muted(muted: boolean): void
  • Property that states whether this plugin considers itself muted based on internal logic. Triggers internal event of type PlayerInternalEventType.MutedChanged if property value was changed.

    Returns boolean

  • Property that states whether this plugin considers itself muted based on internal logic. Triggers internal event of type PlayerInternalEventType.MutedChanged if property value was changed.

    Parameters

    • muted: boolean

    Returns void

version

  • get version(): string
  • Property describing the plugin name and version.

    Returns string

Methods

addEventListener

  • addEventListener(type: string, callback: Listener): void
  • Adds an event listener for a specific event.

    Parameters

    • type: string

      Event type.

    • callback: Listener

      Listener callback function.

    Returns void

createTrack

  • createTrack(nativeElement: HTMLMediaElement, channelCount?: number, id?: string): void
  • Create a track based on a given native element.

    Note! In order to enable individual channel control feature the native element must have property crossOrigin = "anonymous".

    Parameters

    • nativeElement: HTMLMediaElement

      Existing DOM element to control.

    • Optional channelCount: number

      Optional. Number of audio channels in the stream.

    • Optional id: string

      Optional. Identifier of the created track, defaults to src of nativeElement.

    Returns void

destroy

  • destroy(): void
  • Unregisters itself with the player and removes all internal and external event listeners.

    Returns void

disableTrack

  • disableTrack(id: string): void
  • Disables a discrete audio track by detaching all event listeners and removing it from the DOM.

    Parameters

    • id: string

      Identifier of the track.

    Returns void

enableTrack

  • enableTrack(id: string): void
  • Find and enable an internal track. Function will create and insert a native audio element.

    Parameters

    • id: string

      Track id.

    Returns void

getPluginActions

  • getPluginActions(): PluginAction[]
  • Plugin actions are optional and by default a plugin does not contain any actions.

    Returns PluginAction[]

getTrackOffset

  • getTrackOffset(id: string): number
  • Get the current offset for a specific track in seconds.

    Parameters

    • id: string

      the identifier of the track.

    Returns number

initDiscreteAudioTracks

  • Takes external audio track objects and converts them to the internal representation. Every track that is enabled will be created and added to the DOM directly, if they don't already have a related nativeElement.

    Parameters

    Returns void

mute

  • mute(id?: string): void
  • Mutes a specific Playable, or all Playables, depending on the input parameter.

    Parameters

    • Optional id: string

      Optional. If set, mute that specific audio track. In unset, mute all.

    Returns void

off

  • off(type: string, callback: Listener): void
  • Alias method for removeEventListener.

    Parameters

    • type: string

      Event type.

    • callback: Listener

      Listener callback function.

    Returns void

on

  • on(type: string, callback: Listener): void
  • Alias method for addEventListener.

    Parameters

    • type: string

      Event type.

    • callback: Listener

      Listener callback function.

    Returns void

removeEventListener

  • removeEventListener(type: string, callback: Listener): void
  • Removes an event listener for a specific event.

    Parameters

    • type: string

      Event type.

    • callback: Listener

      Listener callback function.

    Returns void

removeTrack

  • removeTrack(id: string): void
  • Removes a track by detaching all event listeners and removing it from list of internal tracks.

    Parameters

    • id: string

      Identifier of track to remove.

    Returns void

setTrackOffset

  • setTrackOffset(id: string, offset: number): void
  • Set offset for a specific track. Seek the track to match its new position if active.

    Parameters

    • id: string

      The identifier of the track

    • offset: number

      The new offset for the track in seconds.

    Returns void

unmute

  • unmute(id?: string): void
  • Unmutes a specific Playable, or all Playables, depending on the input parameter.

    Parameters

    • Optional id: string

      Optional. If set, unmute that specific audio track. In unset, unmute all.

    Returns void