# Live Stream

![](/files/-MX6RqyGv_Z11_GjLppB)

{% hint style="warning" %}
There is a limitation to the maximum number of concurrent live events. Reach out to us at[ community.social.plus.co](https://community.amity.co/) with your use-case and we will determine if the current limit can be raised.
{% endhint %}

### Create a stream&#x20;

To create a stream, follow the code below. This will return an instance of the created `Stream`.

\
**isSecure**: By setting `isSecure` as  `true` the created stream will be available as `https` url.

{% hint style="info" %}
Note that the TypeScript SDK does not support broadcasting a live stream directly. Instead, it allows the creation of a stream object. You can then retrieve the streaming URL from this object and implement it with a third-party library or a streaming tool like OBS.
{% endhint %}

{% tabs %}
{% tab title="iOS" %}
{% embed url="<https://gist.github.com/amythee/7de66470a4630e01f19864e39c0234f0>" %}
{% endtab %}

{% tab title="Android" %}
{% embed url="<https://gist.github.com/1d8c8f2000ec3ccb85687e57131aac8b>" %}
{% endtab %}

{% tab title="Typescript" %}
{% embed url="<https://gist.github.com/amythee/75cdb3d62f3d3bb986a66eeb83b9de8e>" %}
{% endtab %}
{% endtabs %}

### Create child streams

The SDK supports creating a post with multiple streams, and the **AmityStream** object maintains the parent–child relationship. In the case of a stream post, only the parent stream will be linked to the post.

To create a child stream that is related to a parent stream, the **parentStreamId** must be passed as a parameter, and the parent stream must be created first.

{% tabs %}
{% tab title="iOS" %}
{% embed url="<https://gist.github.com/amythee/5d92b154be82fbd75dfc10c858ad76c8>" %}
{% endtab %}

{% tab title="Android" %}
{% embed url="<https://gist.github.com/39145812d944042f502eab53e9dab78e>" %}
{% endtab %}

{% tab title="Typescript" %}
{% embed url="<https://gist.github.com/887be9c7c8f766c719695b8aa823de61>" %}
{% endtab %}
{% endtabs %}

The following fields are added to the **AmityStream** object to specify the relationship:

* **isParent**: `true` if the stream is a parent, `false` if the stream is a child
* **parentStreamId**: the ID of the parent stream
* **childStreamIds**: contains all child streams of the parent stream

To retrieve the child stream objects, we provide the **getChildStreams** property inside the parent stream object.

{% tabs %}
{% tab title="iOS" %}
{% embed url="<https://gist.github.com/amythee/4fb6ad5ded37698551c478ac39931a03>" %}
{% endtab %}

{% tab title="Android" %}
{% embed url="<https://gist.github.com/455112924bfd62a804be81473925b9b7>" %}
{% endtab %}

{% tab title="Typescript" %}
{% embed url="<https://gist.github.com/4e409d1cd9bc5bf5b621a1797211d63f>" %}
{% endtab %}
{% endtabs %}

### Enable live chat channel and reaction in a stream

The **livestream chat** and **reaction** features are enabled by setting the `channelEnabled` field when creating a stream object.\
These features are supported **only** for livestream posts created within a community.

{% tabs %}
{% tab title="iOS" %}
{% embed url="<https://gist.github.com/amythee/7e76c3813948b784c72d1823d9b79fb1>" %}
{% endtab %}

{% tab title="Android" %}
{% embed url="<https://gist.github.com/0b0d4ff7de9725a119e8488f04ab66ae>" %}
{% endtab %}

{% tab title="Typescript" %}
{% embed url="<https://gist.github.com/amythee/be1315f1e0b75dc63c7c2d3816a169f8#file-getlivechat-ts>" %}
{% endtab %}
{% endtabs %}

\
After creating a stream post, the stream object will include the following properties to indicate related information:

<pre class="language-json"><code class="lang-json">{
  ...
<strong>  referenceId: 'postId',
</strong>  referenceType: 'post',
  targetId: 'communityId',
  targetType: 'community',
  postId: 'postId',
  channelId: 'channelId',
  channelEnabled: true,
  ...
}
</code></pre>

**Note:** When `getLiveChat()` is called on the **streamer** side, the SDK creates a new live chat channel linked to the stream **if one does not already exist**. On the **viewer** side, calling `getLiveChat()` returns the live chat channel object **only if it has already been created**.

### Delete a stream&#x20;

To delete a stream, you will need the ID of the stream that you want to delete. The function will return true if successfully deleted, otherwise, it will throw an error.

{% tabs %}
{% tab title="Typescript" %}
{% embed url="<https://gist.github.com/amythee/f80fd898ee60c0e078cb41e9843d0b80>" %}
{% endtab %}
{% endtabs %}

### Dispose a stream&#x20;

Disposing a stream means updating the streaming status to ended and invalidating the streaming URL.&#x20;

To dispose a stream, you need the ID of the stream that you want to dispose. The function will return true if successfully deleted, otherwise, it will throw an error.

{% tabs %}
{% tab title="iOS" %}
{% embed url="<https://gist.github.com/amythee/61fd4e82636a161186776440b083aab3>" %}
{% endtab %}

{% tab title="Android" %}
{% embed url="<https://gist.github.com/a720413f18381aa4c35aa91b3891f76d>" %}
{% endtab %}

{% tab title="Typescript" %}
{% embed url="<https://gist.github.com/amythee/5ec52719ca044545369b9964850c0c41>" %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.social.plus/social-plus-sdk/video/live-stream.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
