Discrete audio plugin

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

Constructors

  • 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

name: string
Name: string = DISCRETE_AUDIO_PLUGIN_NAME

Accessors

  • get isMaxLimitReached(): boolean
  • Returns true if the max number of active tracks is reached, false otherwise

    Returns boolean

  • get loaded(): 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.

    Returns boolean

  • set loaded(loaded): void
  • Parameters

    • loaded: boolean

    Returns void

  • get muted(): 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.

    Returns boolean

  • set muted(muted): void
  • Parameters

    • muted: boolean

    Returns void

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

    Returns string

Methods

  • Adds an event listener for a specific event.

    Parameters

    • type: string

      Event type.

    • callback: Listener

      Listener callback function.

    Returns 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

  • Unregisters itself with the player and removes all internal and external event listeners.

    Returns 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

  • Find and enable an internal track. Function will create and insert a native audio element.

    Parameters

    • id: string

      Track id.

    Returns void

  • Plugin actions are optional and by default a plugin does not contain any actions.

    Returns PluginAction[]

  • Get the current offset for a specific track in seconds.

    Parameters

    • id: string

      the identifier of the track.

    Returns number

  • 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

  • Check if audio track with identifier id is active or not.

    Parameters

    • id: string

      identifier.

    Returns boolean

    true if active, else false.

  • Returns true if it is possible to enable the given track

    Parameters

    • id: string

      the track id

    Returns boolean

  • 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

  • Alias method for removeEventListener.

    Parameters

    • type: string

      Event type.

    • callback: Listener

      Listener callback function.

    Returns void

  • Alias method for addEventListener.

    Parameters

    • type: string

      Event type.

    • callback: Listener

      Listener callback function.

    Returns void

  • Removes an event listener for a specific event.

    Parameters

    • type: string

      Event type.

    • callback: Listener

      Listener callback function.

    Returns 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

  • 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

  • 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