To broadcast a live stream video, we have provided a convenient broadcaster tool called AmityStreamBroadcaster
. You will need to import AmityLiveVideoBroadcastKit.framework
into your app.
AmityStreamBroadcaster
requires the following permissions to work properly.
Camera access
Microphone access
Before using AmityStreamBroadcaster
, please make sure these permissions are already granted.
Here are the steps to ask for the permissions.
Add NSCameraUsageDescription
to your app's info.plist
.
Add NSMicrophoneUsageDescription
to your app's info.plist
.
Call AVCaptureDevice.requestAccess(for: .video, completion: ...)
Call AVAudioSession.sharedInstance().requestRecordPermission(_:)
You can create broadcaster instance by providing AmityClient
.
Before going live, you will need to set up the broadcaster session by creating AmityStreamBroadcasterConfiguration
. This configuration will be applied for the next live session.
The broadcaster object provides "preview view". After finish setting up the broadcaster, you then can take the preview view to attach into your screen.
You can set up video resolution anytime "before" going live. This setting will affect both the rendering of preview view, and the resolution of live stream session.
To begin broadcasting the live stream, call
To stop broadcasting the live stream, call
By default, the broadcaster will use the back camera. However, you can switch camera position anytime by calling
To observe a broadcaster state, we provide a delegate object that you can set to listen to broadcaster's events.
AmityStreamBroadcasterState
represents all the possible states.
.idle
indicates a state of stream in an idle state.
.connecting
indicates a state of stream that it's connecting to the stream server.
.connected
indicates a state of stream that it's connected to the stream server.
.disconnected
indicates a status of stream that it's disconnected.
The code below shows an example of printing out the state of broadcaster, when it changes.
Host your events virtually and see community interaction as it happens
Live streams and playback videos information are stored in AmityStream
. This stream objects reside in AmityStreamRepository
. To start working with stream, first the app need to intialize the repository.
*Note : There is a limitation for the maximum concurrent live events. Please feel free to reach out to us at 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, call
repository.getStreamById(_:)
This function returns a Live Object of AmityStream
. The stream object contains essential data, for example, title and description.
Stream consists of many states. It can change from one state to another, depending on events and actions.
AmityStreamStatus
represents a stream status. The following enum cases describe all the possible status 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 progress of transforming to a recorded stream."
.recorded
indicates "a stream has ended broadcasting and has been transformed to a recorded stream."
You can check the status of a stream by calling .status
.
To query streams collection, first you need to create a AmityStreamCollectionQuery
.
Then call .getStreamsCollection(from:)
with the query object that you've created.
.getStreamsCollection(from: query)
This function returns the live collection of stream objects.
If your app needs stream collections in many parts of the app. We recommend to maintain only one collection for each query, in an application scope. And use it as a single source of truth.
Use AmityVideoPlayer to play a live stream.
To play a live stream, currently only RTMP protocol is supported, call
stream.watcherUrl
AmityLiveStreamURLInfo
contains a full RTMP url, which most of RTMP players support. For some players that does not support the full url, this object contains enough data for custom RTMP url formatting.
AmityStream
has isLive
property.
When there is an update of live object, use isLive
property to check.
When there is an update of live stream collections:
The streams that are not live, will disappear from the collection.
The streams that are just live, will appear in the collection.
RTMP is a low-latency video streaming protocol, that iOS does not support in its native video player. Therefore when working with RTMP, here are some open-source players that we recommend:
Live streams are recorded, and saved as files after the session ends. It would take some time for preparing recorded videos to be ready. You can observe the collection of stream that has recorded videos available.
Use AmityRecordedStreamPlayer to play recorded videos. If the live stream session contains multiple recorded video, player will play one video after another.
Each live stream session can contain multiple recorded videos. You can retrieve the array of AmityLiveVideoRecordingData
that store all recording data, by calling
stream.recordingData
To get the actual url, you need to specify the file format by calling on a recorded item.
recordingItem.url(for: AmityLiveVideoRecordingFileFormat)
The following code shows an example of getting all the mp4 url of a stream instance.
In contrast with RTMP live videos, you don't need 3rd party video players for the recorded videos. iOS native players already support playing mp4 file from the URL given by API.
Amity Video SDK includes AmityVideoPlayerKit.framework
, a basic RTMP player to support live video functionality.
This player is the part of the Amity Video SDK, built as a subclass of AVPlayer for playing recorded livestream videos. It works seamlessly with AVPlayerViewController.
See also and .
This framework requires MobileVLCKit.framework
as a dependency. You can download the framework from the link provided in the .
Ensure that your users don’t miss important content from each other
This functionality is not currently supported for IOS but will be coming soon! We will update the relevant sections accordingly
This module allows for richer, interactive experiences by enabling video stories and live streaming on your application
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.