Skip to content

Latest commit

 

History

History
78 lines (54 loc) · 2.41 KB

File metadata and controls

78 lines (54 loc) · 2.41 KB
sidebar_position 7

import AudioNodePropsTable from "@site/src/components/AudioNodePropsTable" import { Optional, ReadOnly } from '@site/src/components/Badges';

StreamerNode

:::caution Mobile only. :::

The StreamerNode is an AudioScheduledSourceNode which represents a node that can decode and play Http Live Streaming data. Similar to all of AudioScheduledSourceNodes, it can be started only once. If you want to play the same sound again you have to create a new one.

AudioNode properties

Constructor

constructor(context: BaseAudioContext, options?: StreamerOptions)

StreamerOptions

Parameter Type Default
streamPath string - Initial value for streamPath

Or by using BaseAudioContext factory method:

BaseAudioContext.createStreamer().

Example

import React, { useRef } from 'react';
import {
  AudioContext,
  StreamerNode,
} from 'react-native-audio-api';

function App() {
  const audioContextRef = useRef<AudioContext | null>(null);
  if (!audioContextRef.current) {
    audioContextRef.current = new AudioContext();
  }
  const streamer = audioContextRef.current.createStreamer();
  streamer.initialize('link/to/your/hls/source');
  streamer.connect(audioContextRef.current.destination);
  streamer.start(audioContextRef.current.currentTime);
}

Properties

It inherits all properties from AudioScheduledSourceNode.

Name Type Description
streamPath string String value representing url to stream.

Methods

It inherits all methods from AudioScheduledSourceNode.

initialize

Initializes the streamer with a link to an external source.

Parameter Type Description
streamPath string Link pointing to an external source

Returns boolean indicating if setup of streaming has worked.