Skip to content

Methods

0.5.1#

General#

Constructor#

SyncStage(
        private val ctx: Context,
        var userDelegate: SyncStageUserDelegate? = null,
        var connectivityDelegate: SyncStageConnectivityDelegate? = null
    )

Constructor parameters:

  • ctx - Android application context

  • userDelegate - delegate object to receive events about users in session state

  • connectivityDelegate - delegate object to receive events with information about stream connection to Studio Server state

Initialize#

Initializes the SDK SyncStage object.

fun init(
        applicationSecretKey: String? = null,
        onCompleted: (errorCode: SyncStageSDKErrorCode) -> Unit = {},
    )

Parameters:

  • applicationSecretKey - if set to null, SDK will look for applicationSecretKey in the SyncStageSecret.json file

  • onCompleted - callback informing about the result of initialization with SyncStageSDKErrorCode

Stop and dispose#

This method stops and cleans up all background tasks SDK performs.

fun stop()

Note

It is crucial to call it onDestroy of the Activity where SyncStage has been initialized in.

    override fun onDestroy() {
        if (isFinishing) {
            syncStage.stop()
        }
        super.onDestroy()
    }

Get SyncStage SDK version#

Gets SyncStage SDK version

fun getSDKVersion(): String

Get best available server#

Get best available server, where a session can be created

suspend fun getBestAvailableServer(): Pair<ServerInstance?, SyncStageSDKErrorCode>

Get server instances#

Get server instances so you can select the server that is suitable for your session.

suspend fun getServerInstances(): Pair<List<ServerInstance>?, SyncStageSDKErrorCode> 

Session#

Create a session#

Creates a session in a given zone by a given user from your user pool.

suspend fun createSession(
    zoneId: String,
    studioServerId: String,
    userId: String
): Pair<SessionIdentifier?, SyncStageSDKErrorCode>

Parameters:

  • zoneId - zone in which we want to host our session
  • studioServerId - id of the selected studio server
  • userId - id of your app user to match the data between SyncStage and your backend

Join the session#

Joins a particular session identified by sessionCode.

suspend fun join(
    sessionCode: String,
    userId: String,
    displayName: String? = null,
    zoneId: String,
    studioServerId: String,
): Pair<Session?, SyncStageSDKErrorCode> 

Parameters:

  • sessionCode - the session code

  • userId - id of your app user to match de data between SyncStage and your backend

  • displayName - your app user display name

  • zoneId - zone in which your session is hosted

  • studioServerId - studio server where you are running your session

Get session state#

Gets state of currently joined session.

session(completion: @escaping (Result<Session, SyncStageError>)

Parameters:

  • completion - returns session state

Leave the session#

Leaves currently joined session.

suspend fun leave(): SyncStageSDKErrorCode

Audio setup#

Mute / unmute microphone#

Enables or disables microphone stream.

fun toggleMicrophone(mute: Boolean): SyncStageSDKErrorCode 

Parameters:

  • mute- desired state of the mute option

Is muted#

Returns state of microphone stream.

fun isMicrophoneMuted(): Boolean

Turn on / of direct monitor#

Turns on / of direct monitor.

fun toggleDirectMonitor(enable: Boolean): SyncStageSDKErrorCode

Parameters:

  • enable- true for turning on direct monitor

Get direct monitor volume#

Returns current direct monitor volume.

fun getDirectMonitorVolume(): Int

Change direct monitor volume#

Changes volume of the direct monitor.

fun changeDirectMonitorVolume(volume: Int): SyncStageSDKErrorCode 

Parameters:

  • volume- value from range [0;100]

Get direct monitor state#

Gets direct monitor enabled state

fun getDirectMonitorEnabled(): Boolean

Turn on / of internal microphone#

Turns on / of internal microphone to be used instead of default audio input i.e. headphones mic.

fun toggleInternalMic(enable: Boolean): SyncStageSDKErrorCode

Parameters:

  • enable- true for turning on internal microphone

Get internal microphone state#

Gets internal microphone enabled state

fun getInternalMicEnabled(): Boolean

Network measurements#

Get receiver network measurements#

Returns Mesurements object with network delay, jitter, and calculated network quality indicators.

fun getReceiverMeasurements(identifier: String): Measurements

Parameters:

  • identifier- receiver's identifier

Get transmitter network measurements#

Returns Mesurements object with network delay, jitter, and calculated network quality indicators.

fun getTransmitterMeasurements(): Measurements

Session recording#

Start recording#

fun startRecording(): SyncStageSDKErrorCode

Stop recording#

fun stopRecording(): SyncStageSDKErrorCode