LiveKit
LiveKit is a component of the WandKit framework that provides functionalities such as screen sharing, keeping the screen active, and auto-connecting to the Nativeblocks Studio environment. It is tailored for Android applications and integrates seamlessly with the Nativeblocks ecosystem.
Features
- Screen Sharing:
- Enable or disable screen sharing during live sessions.
- Keep Screen On:
- Prevents the device screen from turning off automatically.
- Auto-Connect:
- Simplifies live session workflows by automatically connecting to the environment.
LiveKit
class LiveKit : WandKit
Inheritance
Implements: WandKit
Constructor
Initializes the LiveKit module with configurable options.
LiveKit(
screenSharing: Boolean = false,
keepScreenOn: Boolean = true,
autoConnect: Boolean = true
)
Parameters
- screenSharing: Enables or disables screen sharing functionality (default: false).
- keepScreenOn: Keeps the device screen active during live sessions (default: true).
- autoConnect: Automatically connects to the live environment (default: true).
Methods
setup
Configures the LiveKit instance with the provided context and Nativeblocks edition.
override fun setup(context: Context, edition: NativeblocksEdition)
Parameters
- context: The Android Context used to initialize the live service.
- edition: The NativeblocksEdition (Cloud or Community). LiveKit is only supported for the Cloud edition.
Exceptions
- Throws IllegalAccessException if the Community edition is used.
destroy
Destroys the LiveKit instance and cleans up resources.
override fun destroy()
Sample Usage
Here’s an example of how to configure and use LiveKit in an Android application:
import android.app.Application
import io.nativeblocks.core.api.NativeblocksManager
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// Initialize NativeblocksManager
NativeblocksManager.initialize()
// Configure LiveKit for debug builds
if (BuildConfig.DEBUG) {
NativeblocksManager.getInstance().liveKit(
screenSharing = true, // Enable screen sharing
keepScreenOn = true, // Keep the screen active
autoConnect = false // Disable auto-connect
)
}
}
}
Extension Function
liveKit
Initializes a LiveKit instance for the NativeblocksManager.
fun NativeblocksManager.liveKit(
screenSharing: Boolean = false,
keepScreenOn: Boolean = true,
autoConnect: Boolean = true
): NativeblocksManager
Parameters
- screenSharing: Enables or disables screen sharing functionality (default: false).
- keepScreenOn: Keeps the device screen active during live sessions (default: true).
- autoConnect: Automatically connects to the live environment (default: true).
Returns
The NativeblocksManager instance with the configured LiveKit.