Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Latest commit

 

History

History
66 lines (48 loc) · 3.5 KB

useLiveStreaming.md

File metadata and controls

66 lines (48 loc) · 3.5 KB

useLiveStreaming

The useLiveStreaming hook gathers functions responsible for managing Live Streaming.

Important

Live Streaming can only be started and stopped through the api call to dedicated backend service, which has to be created by the user. Example backend service can be found here. // CHANGE TO PROPER GITHUB REPO! The SDK itself doesn't provide methods for this.

Members

Name Type Description
owner Participant The object of the participant who started the live stream.
startLiveStreaming (start: () => Promise) => Promise Starts Live Streaming. User has to pass his own start method connected with backend service
stopLiveStreaming (stop: () => Promise) => Promise; Stops Live Streaming. User has to pass his own start method connected with backend service
isLiveStreamingModeActive boolean Informs if local user has active Live Streaming mode.
isLocalUserLiveStreamingOwner boolean Informs if local user is live stream owner.
status Status Current live stream status
resetLiveStreamingData () => void Resets data of Live Streaming for local user.
timestamp number / null Informs when Live Streaming started.
provider 'youtube' / 'facebook' / 'twitch' / null Informs where user is Live Streaming, if it can be determined from rtmp url
setLiveStreamingErrors (error?: ErrorCodes) => void Function for resetting errors or adding specific error.
isError boolean Informs if any live stream error occurs.

Examples

React

Start Live Streaming

const { startLiveStreaming } = useLiveStreaming();

const startOnBackend = async () => {
  const res = await fetch(`http://backend.com/start`, {
    method: 'POST',
  });
  return res;
};

await startLiveStreaming(startOnBackend);

Stop Live Streaming

const { stopLiveStreaming } = useLiveStreaming();

const stopOnBackend = async () => {
  const res = await fetch(`http://backend.com/stop`, {
    method: 'POST',
  });
  return res;
};

await stopLiveStreaming(stopOnBackend);

Display Live Streaming owner name

const { owner } = useLiveStreaming();

<Text>{`${owner.info.name} is Live Streaming ...`}</Text>;