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

Latest commit

 

History

History
72 lines (53 loc) · 5.96 KB

useLiveStreaming.md

File metadata and controls

72 lines (53 loc) · 5.96 KB

useLiveStreaming

The useLiveStreaming hook gathers functions responsible for managing Live Streaming.

import { useLiveStreaming } from '@dolbyio/comms-uikit-react';

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. 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<boolean>) => Promise<boolean> Starts Live Streaming. User has to pass his own start method connected with backend service
stopLiveStreaming (stop: () => Promise<boolean>) => Promise<boolean>; Stops Live Streaming. User has to pass his own start method connected with backend service
startLiveStreamingByProxy (baseUrl: string, rtmpUrl: string) => Promise A handy function to start live streaming using a proxy server. Note: please don't use this function if your own proxy server implementation is different to the dolby.io demo proxy server, instead please use startLiveStreaming
stopLiveStreamingByProxy (baseUrl: string) => Promise A handy function to stop live streaming using a proxy server. Note: please don't use this function if your own proxy server implementation is different to the dolby.io demo proxy server, instead please use stopLiveStreaming
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>;