Every action inside of ts-sdk can be wrapped by runQuery
to enable offline first functionality.
For a getter, runQuery
will first try to get the data from cache. If the data already exists in the cache, it will not fetch from the server. Otherwise, it will fetch the data and store the cache accordingly.
You can set the period of validity of the cache manually using the third parameter. With this example, the cache will be considered valid for an hour.
For a mutator, runQuery
will do an optimistic mutation (creation, update, delete operation) to the cache before making a request to the server.
The runQuery
for an action that requires pagination acts a little differently. Instead of accepting a callback that passes just the object of interest, it will also pass a pages
object with the key prevPage
and nextPage
referring to the Amity.Page
object that can be used to query the previous page and the next page, respectively. A sample code is provided below:
This module allows for richer, interactive experiences by enabling video stories and live streaming on your application
Chrome: 38+
Firefox: 42+
Microsoft Edge: 13+
Safari: 9+
Opera: 25+
Amity Web SDK probably won't work great in Internet Explorer 11. We generally support the recent versions of major browsers listed above.
Since Amity Web SDK uses local cache for performance and user experience reason, server side rendering is not supported. To use Amity Web SDK with NextJS, Amity Web SDK must be imported using Dynamic Import with SSR disabled.
For details on using the TypeScript SDK with React Native, refer to these installation notes.
More than ever, videos are increasingly dominating mobile screens. From fun short-form clips to promote new products to live-streamed talk shows to educate your customers, videos have the potential to transform the way customers experience your brand.
Host your events virtually and see community interaction as it happens
Live streams and playback videos information are stored in Amity.Stream
. To start working with stream, first, the app needs to initialize the repository. To create a new SDK instance with your API key, refer to the Initialization section.
There is a limitation for the maximum concurrent live events. Please feel free to reach out to us at community.amity.co with your use-case and we will determine if the current limit can be raised.
Each stream object has a unique identifier. To retrieve a single stream object. The stream object contains essential data such as title, description, streamerUrl, watcherUrl, etc
Stream consists of many states. It can change from one state to another, depending on events and actions.
Amity.StreamStatus.<STATUS>
represents a stream status. The following enum cases describe all the possible statuses of a stream.
IDLE
indicates "a stream that has generated but no actions have been taken."
LIVE
indicates "a stream is currently being broadcasted."
ENDED
indicates "a stream has ended broadcasting and in the process of transforming to a recorded stream."
RECORDED
indicates "a stream has ended broadcasting and has been transformed to a recorded stream."
You can query a list of stream by calling queryStream
.
To play a live stream, currently FLV, RTMP and HLS protocol are supported by using watcherUrl
inside the stream object.
To play a recorded stream, currently FLV, MP4 and M3U8 protocol are supported by using recordings
inside the stream object.
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 streaming tools like OBS.
To stop broadcasting a live stream, you can use the dedicated stop function provided by the SDK. This function will explicitly end the ongoing live stream and change its status to 'ENDED' Using this function is crucial for effectively managing your live streams and ensuring that they transition properly to their recorded state after broadcasting. Here's how you can use the function:
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.