interface AudioApi {
    onAudioContextChange$: Observable<AudioContextChangeEvent>;
    onAudioLoaded$: BehaviorSubject<undefined | AudioLoadedEvent>;
    onAudioPeakProcessorWorkletNodeMessage$: Observable<AudioPeakProcessorWorkletNodeMessageEvent>;
    onAudioRouting$: Observable<AudioRoutingEvent>;
    onAudioSwitched$: Observable<AudioSwitchedEvent>;
    createAudioContext(inputsNumber: number, outputsNumber?: number): Observable<void>;
    createAudioContextWithOutputsResolver(inputsNumber: number, outputsNumberResolver: ((maxChannelCount: number) => number)): Observable<void>;
    createAudioPeakProcessorWorkletNode(audioMeterStandard: AudioMeterStandard): 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 full)

Properties

onAudioContextChange$: Observable<AudioContextChangeEvent>

Fires on AudioContext creation

onAudioLoaded$: BehaviorSubject<undefined | AudioLoadedEvent>

Fires on subtitles load. Initial value is undefined.

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

    • 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

        • (maxChannelCount): number
        • Parameters

          • maxChannelCount: number

          Returns number

    Returns Observable<void>

  • Creates AudioWorkletNode and attaches it to AudioContext input. It can be used for audio peak processing and gathering live volume levels data

    Parameters

    • audioMeterStandard: AudioMeterStandard

    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>