Getting Started
The SDK provides the NwCore singleton class through which you can access all of the SDKs functionalities.
The SDK requires the RECORD_AUDIO permission for recording audio, if second screen sync should be available.
The first step to initialize the SDK is to instantiate and initialize the NwCore.
The NwCoreImpl.Builder(this).build()part is where the actual initialization happens. It appears that NwCoreImpl.Builder is a builder class for creating NwCoreImpl instances. It follows the Builder design pattern, where build() is typically the final function that returns a newly created object.
Alternatively, you can call NwCore as a lateinit property:
NwCore can be initialized by using Hilt like this:
Once you have the nwCoreSDK, you need to initialize expPlayback, which serves as the engine of the Nw EXP. Additionally, you can set the environment and locale, which are optional, in a Compose View.
- Manifest Identifiers:
- expManifestId: A unique identifier for the experience manifest, essential for fetching the correct multimedia content.
- GUI Overlay URL:
- An overlay URLverlayUrl) is defined to act as the player's controller, offering additional information and controls over the multimedia content.
- NwCore SDK Configuration:
- Sets the SDK environment to production ( NwEnvironment.PROD) and specifies the locale ( "en").
- Initializes the audio synchronization service with the experience manifestID and the configured synchronization contents.
- Experience Playback Service Initialization:
- Utilizes the audioSyncService (explain later) to initialize the experiencePlaybackService, which is responsible for managing the multimedia content playback.
nwCoreSDK.ExpComposeView
This function is part of the NwCoreSDK and is responsible for displaying a multimedia experience within a Jetpack Compose layout. It integrates audio synchronization and playback services to provide a rich user experience with multimedia content.
- context: Context- The Android context, used for accessing resources and system services.
- audioSyncCallback: (() -> Unit)?- An optional callback for audio synchronization events. This can be null if no callback behavior is desired.
- expPlaybackService: ExperiencePlaybackService- The playback service instance responsible for managing the multimedia content playback.
- guiOverlayUrl: String?- The URL for the graphical user interface overlay. This URL points to a web resource that provides additional information or controls over the multimedia experience.
- onError: (Throwable) -> Unit- A callback function invoked when an error occurs during playback. It receives the error as a parameter.
- onCustomAction: (String) -> Unit- A callback function triggered by custom actions within the multimedia experience. The specific action is passed as a String parameter.
- exitPlayback: () -> Unit- A function to be called when exiting playback. This is typically used to clean up resources and navigate away from the playback experience.
- onCheckAudioPermission: () -> Unit- A callback function invoked to check and request audio permissions from the user. This ensures that the app has the necessary permissions to play audio content.
To terminate the EXP, you have to call terminateExpPlaybackService() of ExperiencePlaybackService object.
expPlayback.value.terminateExpPlaybackService(): This method is part of the ExperiencePlaybackService and is designed to terminate the all the Nw Exp services. It is responsible for stopping any ongoing playback, releasing resources, and performing any necessary cleanup to ensure that the service is gracefully shut down.
Proper termination of the playback service is essential for resource management and application performance. After calling terminateExpPlaybackService(), the expPlayback will be compromised, necessitating the reinitialization of the expPlayback.
- Preparation: The code begins by setting up various identifiers and endpoints required for the experience, including those for the experience manifest, content library, direct synchronization, and the SMDS endpoint.
- SDK Configuration: The NwCore SDK is configured for production use with a specified locale, and the necessary services for audio synchronization and experience playback are initialized.
- Service Initialization: With the synchronization contents prepared, the audio sync service is initialized, followed by the experience playback service, marking the completion of the setup for multimedia content playback.
It's crucial to initialize an ExperiencePlaybackService object at the start to prevent any unexpected behaviors or errors during its operation.
The NwCore SDK is utilized within a Jetpack Compose application to create immersive multimedia experiences, enabling advanced features like synchronized content playback and interactive GUI overlays. It offers a comprehensive framework for managing multimedia content, ensuring efficient resource utilization and seamless user engagement through proper initialization and cleanup routines.
Depending on your configuration, an event-specific experience or the default experience will be loaded and the second screen sync option will be available, or not. For more information about the different options, please check the Guides & Tutorials chapter.