interface AudioApi {
    onAudioContextChange$: Observable<AudioContextChangeEvent>;
    onAudioLoaded$: Observable<undefined | AudioLoadedEvent>;
    onAudioPeakProcessorWorkletNodeMessage$: Observable<
        AudioPeakProcessorWorkletNodeMessageEvent,
    >;
    onAudioRouting$: Observable<AudioRoutingEvent>;
    onAudioSwitched$: Observable<AudioSwitchedEvent>;
    createAudioContext(contextOptions?: AudioContextOptions): Observable<void>;
    createAudioPeakProcessorWorkletNode(
        audioMeterStandard: AudioMeterStandard,
    ): Observable<void>;
    createAudioRouter(
        inputsNumber: number,
        outputsNumber?: number,
    ): Observable<void>;
    createAudioRouterWithOutputsResolver(
        inputsNumber: number,
        outputsNumberResolver: (maxChannelCount: number) => number,
    ): Observable<void>;
    getActiveAudioTrack(): undefined | OmakaseAudioTrack;
    getAudioContext(): undefined | AudioContext;
    getAudioInputOutputNodes(): AudioInputOutputNode[][];
    getAudioTracks(): OmakaseAudioTrack[];
    getMediaElementAudioSourceNode(): undefined | MediaElementAudioSourceNode;
    routeAudioInputOutputNode(
        newAudioInputOutputNode: AudioInputOutputNode,
    ): Observable<void>;
    routeAudioInputOutputNodes(
        newAudioInputOutputNodes: AudioInputOutputNode[],
    ): Observable<void>;
    setActiveAudioTrack(id: string): Observable<void>;
}

Hierarchy (View Summary)

Properties

onAudioContextChange$: Observable<AudioContextChangeEvent>

Fires on AudioContext creation

onAudioLoaded$: Observable<undefined | AudioLoadedEvent>

Fires on subtitles load. Initial value is undefined. Always emits the current value on subscription.

onAudioPeakProcessorWorkletNodeMessage$: Observable<
    AudioPeakProcessorWorkletNodeMessageEvent,
>

Fires on event produced by AudioWorkletNode created with createAudioPeakProcessorWorkletNode

onAudioRouting$: Observable<AudioRoutingEvent>

Fires on audio input / output channel connection change

onAudioSwitched$: Observable<AudioSwitchedEvent>

Fires on audio track switched

Methods

  • Creates AudioContext. AudioContext.resume() is invoked on first video play

    Parameters

    • OptionalcontextOptions: AudioContextOptions

    Returns Observable<void>

  • Creates AudioSplitterNode and AudioMergerMode configured for routing between inputsNumber and outputsNumber.

    Parameters

    • inputsNumber: number

      Number of input channels. Implicitly created ChannelSplitterNode is configured with inputsNumber.

    • OptionaloutputsNumber: number

      Number of output channels. Implicitly created ChannelMergerNode is configured with outputsNumber. If not provided outputsNumber is resolved by calling defaultAudioOutputsResolver function:

      const defaultAudioOutputsResolver: (maxChannelCount: number) => number = (maxChannelCount: number) => {
        if (maxChannelCount <= 1) {
          return 1;
        } else if (maxChannelCount >= 2 && maxChannelCount <= 5) {
          return 2
        } else if (maxChannelCount >= 6) {
          return 6
        } else {
          return maxChannelCount;
        }
      }
      

    Returns Observable<void>

  • Creates AudioContext. AudioContext.resume() is invoked on first video play

    Parameters

    • inputsNumber: number
    • outputsNumberResolver: (maxChannelCount: number) => number

      Function to resolve outputsNumber. Provides AudioContext.destination.maxChannelCount as input argument

    Returns Observable<void>

  • Returns undefined | MediaElementAudioSourceNode

    MediaElementAudioSourceNode implicitly created on

  • Routes (connects or disconnects) provided AudioInputOutputNode (connects it or disconnects it)

    Parameters

    • newAudioInputOutputNode: AudioInputOutputNode

    Returns Observable<void>

  • Routes multiple AudioInputOutputNode

    Parameters

    • newAudioInputOutputNodes: AudioInputOutputNode[]

    Returns Observable<void>