Skip to content

Commit

Permalink
docs: livestream component docs
Browse files Browse the repository at this point in the history
  • Loading branch information
khushal87 committed Oct 11, 2023
1 parent 353b3e2 commit 9458afb
Show file tree
Hide file tree
Showing 19 changed files with 268 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "Livestream",
"position": 3
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
id: host-live-stream
title: HostLiveStream
---

import HostLiveStreamTopView from '../../common-content/ui-components/livestream/host-live-stream/host-live-stream-top-view.mdx';
import LiveStreamLayout from '../../common-content/ui-components/livestream/live-stream-layout.mdx';
import HostLiveStreamControls from '../../common-content/ui-components/livestream/host-live-stream/host-live-stream-controls.mdx';
import DurationBadge from '../../common-content/ui-components/livestream/duration-badge.mdx';
import FollowerCount from '../../common-content/ui-components/livestream/follower-count.mdx';
import LiveIndicator from '../../common-content/ui-components/livestream/live-indicator.mdx';
import HostStartStreamButton from '../../common-content/ui-components/livestream/host-live-stream/host-start-stream-button.mdx';
import LiveStreamMediaControls from '../../common-content/ui-components/livestream/live-stream-media-controls.mdx';
import OnStartStreamHandler from '../../common-content/ui-components/livestream/host-live-stream/on-start-stream-handler.mdx';
import OnEndStreamHandler from '../../common-content/ui-components/livestream/host-live-stream/on-end-stream-handler.mdx';

The `HostLiveStream` is the UI component that allows you to show the live stream view in the app on the host's end with minimal efforts. So you don't need to take care much about each feature that you need to build a video live stream call screen with this component.

Basically what you can do with the `HostLiveStream` is:

- A complete live stream UI with ability to stream host's video.
- Duration of the live stream with live indicator.
- Whether the stream is live and number of participant's watching the stream.
- Media controls to control publishing and unpublishing of stream.

Check failure on line 24 in packages/react-native-sdk/docusaurus/docs/reactnative/04-ui-components/livestream/host-live-stream.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] packages/react-native-sdk/docusaurus/docs/reactnative/04-ui-components/livestream/host-live-stream.mdx#L24

[Vale.Spelling] Did you really mean 'unpublishing'?
Raw output
{"message": "[Vale.Spelling] Did you really mean 'unpublishing'?", "location": {"path": "packages/react-native-sdk/docusaurus/docs/reactnative/04-ui-components/livestream/host-live-stream.mdx", "range": {"start": {"line": 24, "column": 44}}}, "severity": "ERROR"}

## General usage

Let's see how to show the `ViewerLiveStream` UI:

```tsx {13}
import {
Call,
StreamCall,
HostLiveStream,
} from '@stream-io/video-react-native-sdk';

const VideoCallUI = () => {
let call: Call;
// your logic to create a new call or get an existing call

return (
<StreamCall call={call}>
<HostLiveStream />
</StreamCall>
);
};
```

## Props

### `hls`

Enable HTTP live streaming

| Type | Default |
| --------- | ------- |
| `boolean` | false |

### `HostLiveStreamTopView`

<HostLiveStreamTopView />

### `LiveStreamLayout`

<LiveStreamLayout />

### `ViewerLiveStreamControls`

<HostLiveStreamControls />

### `DurationBadge`

<DurationBadge />

### `FollowerCount`

<FollowerCount />

### `LiveIndicator`

<LiveIndicator />

### `HostStartStreamButton`

<HostStartStreamButton />

### `LiveStreamMediaControls`

<LiveStreamMediaControls />

### `OnStartStreamHandler`

<OnStartStreamHandler />

### `OnEndStreamHandler`

<OnEndStreamHandler />
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
id: viewer-live-stream
title: ViewerLiveStream
---

import ViewerLiveStreamTopView from '../../common-content/ui-components/livestream/viewer-live-stream/viewer-live-stream-top-view.mdx';
import LiveStreamLayout from '../../common-content/ui-components/livestream/live-stream-layout.mdx';
import ViewerLiveStreamControls from '../../common-content/ui-components/livestream/viewer-live-stream/viewer-live-stream-controls.mdx';
import DurationBadge from '../../common-content/ui-components/livestream/duration-badge.mdx';
import FollowerCount from '../../common-content/ui-components/livestream/follower-count.mdx';
import LiveIndicator from '../../common-content/ui-components/livestream/live-indicator.mdx';
import ViewerLeaveStreamButton from '../../common-content/ui-components/livestream/viewer-live-stream/viewer-leave-stream-button.mdx';
import OnLeaveStreamHandler from '../../common-content/ui-components/livestream/viewer-live-stream/on-leave-stream-handler.mdx';

The `ViewerLiveStream` is the UI component that allows you to show the live stream view in the app with minimal efforts. So you don't need to take care much about each feature that you need to build a video live stream call screen with this component.

Basically what you can do with the `ViewerLiveStream` is:

- A complete live stream UI with host's video, screen sharing stream.
- Duration of the stream.
- Whether the stream is live and number of participant's watching the stream.

## General usage

Let's see how to show the `ViewerLiveStream` UI:

```tsx {13}
import {
Call,
StreamCall,
ViewerLiveStream,
} from '@stream-io/video-react-native-sdk';

const VideoCallUI = () => {
let call: Call;
// your logic to create a new call or get an existing call

return (
<StreamCall call={call}>
<ViewerLiveStream />
</StreamCall>
);
};
```

## Props

### `ViewerLiveStreamTopView`

<ViewerLiveStreamTopView />

### `LiveStreamLayout`

<LiveStreamLayout />

### `ViewerLiveStreamControls`

<ViewerLiveStreamControls />

### `DurationBadge`

<DurationBadge />

### `FollowerCount`

<FollowerCount />

### `LiveIndicator`

<LiveIndicator />

### `ViewerLeaveStreamButton`

<ViewerLeaveStreamButton />

### `OnLeaveStreamHandler`

<OnLeaveStreamHandler />
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Component to customize the Duration badge component on the viewer's live stream's top view.

| Type | Default Value |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ComponentType`\| `undefined` | [`DurationBadge`](https://github.com/GetStream/stream-video-js/blob/main/packages/react-native-sdk/src/components/Livestream/LiveStreamTopView/DurationBadge.tsx) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Component to customize the Follower count indicator on the viewer's live stream's top view.

| Type | Default Value |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ComponentType`\| `undefined` | [`FollowerCount`](https://github.com/GetStream/stream-video-js/blob/main/packages/react-native-sdk/src/components/Livestream/LiveStreamTopView/FollowerCount.tsx) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Component to customize the bottom view controls at the host's live stream.

| Type | Default Value |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `ComponentType`\| `undefined` | [`HostLiveStreamControls`](https://github.com/GetStream/stream-video-js/blob/main/packages/react-native-sdk/src/components/Livestream/LiveStreamControls/HostLiveStreamControls.tsx) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Component to customize the top view at the host's live stream.

| Type | Default Value |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ComponentType`\| `undefined` | [`HostLiveStreamTopView`](https://github.com/GetStream/stream-video-js/blob/main/packages/react-native-sdk/src/components/Livestream/LiveStreamTopView/HostLiveStreamTopView.tsx) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Component to customize the host's start/end live stream button.

| Type | Default Value |
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ComponentType`\| `undefined` | [`HostStartStreamButton`](https://github.com/GetStream/stream-video-js/blob/main/packages/react-native-sdk/src/components/Livestream/LiveStreamControls/HostStartStreamButton.tsx) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Handler to be called when the End Stream button is pressed.

| Type |
| --------------------------- |
| `() => void` \| `undefined` |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Handler to be called when the Start Stream button is pressed.

| Type |
| --------------------------- |
| `() => void` \| `undefined` |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Component to customize the Live indicator on the viewer's live stream's top view.

| Type | Default Value |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ComponentType`\| `undefined` | [`LiveIndicator`](https://github.com/GetStream/stream-video-js/blob/main/packages/react-native-sdk/src/components/Livestream/LiveStreamTopView/LiveIndicator.tsx) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Component to customize the live stream video layout.

| Type | Default Value |
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ComponentType`\| `undefined` | [`LiveStreamLayout`](https://github.com/GetStream/stream-video-js/blob/main/packages/react-native-sdk/src/components/Livestream/LiveStreamLayout/LiveStreamLayout.tsx) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Component to customize the host's media control(audio/video) buttons.

| Type | Default Value |
| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ComponentType`\| `undefined` | [`LiveStreamMediaControls`](https://github.com/GetStream/stream-video-js/blob/main/packages/react-native-sdk/src/components/Livestream/LiveStreamControls/LiveStreamMediaControls.tsx) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Handler to be called when the viewer's leave stream button is called.

| Type |
| --------------------------- |
| `() => void` \| `undefined` |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Component to customize the leave stream button on the viewer's end live stream.

| Type | Default Value |
| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ComponentType`\| `undefined` | [`ViewerLeaveStreamButton`](https://github.com/GetStream/stream-video-js/blob/main/packages/react-native-sdk/src/components/Livestream/LiveStreamControls/ViewerLeaveStreamButton.tsx) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Component to customize the bottom view controls at the viewer's live stream.

| Type | Default Value |
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ComponentType`\| `undefined` | [`ViewerLiveStreamControls`](https://github.com/GetStream/stream-video-js/blob/main/packages/react-native-sdk/src/components/Livestream/LiveStreamControls/ViewerLiveStreamControls.tsx) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Component to customize the top view at the viewer's live stream.

| Type | Default Value |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ComponentType`\| `undefined` | [`ViewerLiveStreamTopView`](https://github.com/GetStream/stream-video-js/blob/main/packages/react-native-sdk/src/components/Livestream/LiveStreamTopView/ViewerLiveStreamTopView.tsx) |
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export const HostStartStreamButton = ({
hls,
}: HostStartStreamButtonProps) => {
const [isAwaitingResponse, setIsAwaitingResponse] = useState(false);
const { useIsCallLive } = useCallStateHooks();
const { useIsCallLive, useIsCallBroadcastingInProgress } =
useCallStateHooks();
const {
theme: {
colors,
Expand All @@ -55,8 +56,11 @@ export const HostStartStreamButton = ({

const call = useCall();
const isCallLive = useIsCallLive();
const isCallBroadcasting = useIsCallBroadcastingInProgress();
const { t } = useI18n();

const liveOrBroadcasting = isCallLive || isCallBroadcasting;

const onStartStreamButtonPress = async () => {
if (onStartStreamHandler) {
onStartStreamHandler();
Expand Down Expand Up @@ -98,13 +102,15 @@ export const HostStartStreamButton = ({
{
backgroundColor: isAwaitingResponse
? colors.dark_gray
: isCallLive
: liveOrBroadcasting
? colors.error
: colors.primary,
},
hostStartStreamButton.container,
]}
onPress={isCallLive ? onEndStreamButtonPress : onStartStreamButtonPress}
onPress={
liveOrBroadcasting ? onEndStreamButtonPress : onStartStreamButtonPress
}
>
<View
style={[
Expand All @@ -115,7 +121,7 @@ export const HostStartStreamButton = ({
>
{isAwaitingResponse ? (
<ActivityIndicator />
) : isCallLive ? (
) : liveOrBroadcasting ? (
<EndBroadcastIcon />
) : (
<StartStreamIcon />
Expand All @@ -131,7 +137,7 @@ export const HostStartStreamButton = ({
>
{isAwaitingResponse
? t('Loading...')
: isCallLive
: liveOrBroadcasting
? t('Stop Livestream')
: t('Start Livestream')}
</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
FollowerCountProps,
} from './FollowerCount';
import { useTheme } from '../../../contexts';
import { useCallStateHooks } from '@stream-io/video-react-bindings';

/**
* Props for the HostLiveStreamTopView component.
Expand Down Expand Up @@ -40,6 +41,12 @@ export const HostLiveStreamTopView = ({
LiveIndicator = DefaultLiveIndicator,
FollowerCount = DefaultFollowerCount,
}: HostLiveStreamTopViewProps) => {
const { useIsCallLive, useIsCallBroadcastingInProgress } =
useCallStateHooks();
const isCallLive = useIsCallLive();
const isBroadcasting = useIsCallBroadcastingInProgress();

const liveOrBroadcasting = isCallLive || isBroadcasting;
const {
theme: { colors, hostLiveStreamTopView },
} = useTheme();
Expand All @@ -59,7 +66,7 @@ export const HostLiveStreamTopView = ({
/>
<View style={[styles.rightElement, hostLiveStreamTopView.rightElement]}>
<View style={[styles.liveInfo, hostLiveStreamTopView.liveInfo]}>
{LiveIndicator && <LiveIndicator />}
{liveOrBroadcasting && LiveIndicator && <LiveIndicator />}
{FollowerCount && <FollowerCount />}
</View>
</View>
Expand Down

0 comments on commit 9458afb

Please sign in to comment.