View & Play Live Stream

Host your events virtually and see community interaction as it happens

Live streams and playback videos information are stored in AmityStream. These stream objects reside in AmityStreamRepository. To start working with stream, first, the app needs to initialize the repository.

val streamRepository = AmityVideoClient.newStreamRepository()

Note : There is a limitation for the maximum number of concurrent live events. Reach out to us at community.amity.co with your use-case and we will determine if the current limit can be raised.

Retrieve a stream object

Each stream object has a unique identifier. To retrieve a single stream object.

This function returns a flowable of AmityStream. The stream object contains essential data, for example, title and description.

streamRepository
       .getStream(streamId)
       .subscribe( {doOnNext} )

Stream Status

Stream consists of many states. It can change from one state to another, depending on events and actions.

Amitystream.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 check the status of a stream by calling stream.getStatus().

Retrieve a stream collection

AmityStreamRepository provides a convenient method getStreamsand also call setStatus(statuses: Array<Amitystream.Status>) to query live streams. We provide enums of stream status as AmityStream.Status

You can observe changes in a collection as per the defined statuses.

  AmityVideoClient.newStreamRepository()
         .getStreams()
         .setStatus(arrayOf(AmityStream.Status.LIVE, AmityStream.Status.RECORDED))
         .build()
         .query()
         .subscribe( {adapter.submitList(it)} )

Play a live stream

Setup

You simply need to include this dependency to your project in build.gradle in the application l

 implementation 'com.github.AmityCo.Amity-Social-Cloud-SDK-Android:amity-video-player:x.y.z'

Inside your Application class, in the application initialization process, you need to register the video player SDK to the core SDK by calling.

  @Override
  open fun onCreate() {
        super.onCreate()
        AmityStreamPlayerClient.setup(AmityCoreClient.getConfiguration())
    }
  

SDK provides AmityVideoPlayer with a capability to play a Live stream based on streamId

From SDK version 6.19.0 onwards, AmityVideoPlayer plays a Live stream with streamId

Play a recorded stream

From SDK version 6.19.0 onwards, recorded stream can only be played with AmityVideoPlayer

SDK provides AmityVideoPlayer with a capability to play a recorded stream based on streamId

Playing stream in Jetpack Compose

By inflating AmityVideoPlayer as AndroidView in Compose, it can seamlessly play live or recorded stream video within the Composable function

Last updated