API Reference
.Please find below an overview of the available APIs for you to use. Also check out the Guides & Tutorials chapter for useful information about using the SDK.
The NwCore interface is a critical part of the SDK that provides functionalities for audio synchronization, experience playback, and the management of experimental manifest services. It acts as a central point for accessing various services and functionalities required for the interactive and multimedia experiences offered by the SDK.
appId: String: The unique identifier for the application.
environment: NwEnvironment: An instance that defines the operational environment settings.
locale: String: The current locale of the application, typically used for localization.
contentProviderUrl: String: The URL to the content provider that supplies media and experience data.
timelineSync: NwTimelineSync: An instance that handles synchronization with the timeline service.
isNwSDKInitialized: Boolean: A boolean flag indicating whether the SDK has been initialized.
audioSyncService(expManifestId: String, syncContents: SyncContents): AudioSyncService?Initiates an audio synchronization service for a given experience manifest. Returns an instance of AudioSyncService or null if the service cannot be initiated.
experiencePlaybackService(expManifestId: String, audioSyncService: AudioSyncService?): ExperiencePlaybackServiceCreates a playback service for a specific experience manifest, optionally using an audio synchronization service.
ExpComposeView(...)A composable function that renders a UI view for the experience playback service with optional GUI overlay, audio synchronization callback, and various event handlers.
expView(context: Context, expPlaybackService: ExperiencePlaybackService, guiOverlayUrl: String?, audioSyncCallback: AudioSyncService.AudioSyncCallback? = null, exitPlayback: () -> Unit, onCheckAudioPermission: () -> Unit, onCustomAction: (payload: String?) -> Unit = {}, onError: (exception: NwException?) -> Unit = {}): ViewCreates a traditional Android View for the experience playback service, similar in functionality to ExpComposeView but for use outside of Jetpack Compose.
checkAudioPermission(isGranted: Boolean)Notifies the SDK of the current audio permission state.
getVersionName(): StringReturns the version name of the SDK.
onDestroy()Cleans up resources and shuts down services when the instance is no longer needed.
- @Composable: Indicates that ExpComposeView is a Jetpack Compose function, allowing it to be used within the Compose UI toolkit.
- DevTools: A property that provides access to developer tools for debugging and development purposes.
- NwException: A custom exception type used for error handling within the SDK functions.
This interface is designed to be implemented by the SDK and used by application developers to integrate multimedia and interactive experiences into their applications. It abstracts the complexities involved in synchronizing audio, managing experimental manifests, and handling experience playback.
The ExperiencePlaybackService interface defines a comprehensive set of functionalities for controlling and managing playback of multimedia experiences, synchronization with audio, and handling of experience manifest data. It offers detailed control over playback and synchronization states, allowing for a robust multimedia experience.
The coroutine scope associated with the playback service for managing asynchronous tasks.
The identifier of the current experience manifest.
Indicates whether offline files are available for playback.
Indicates if the current playback is a live experience.
Reflects the current mute state of the playback.
Indicates if playback is currently active.
Shows whether the playback service is prepared to start playback.
Indicates whether the playback is synchronized with the audio sync service.
Shows if the playback is currently in sync according to the latest checks.
A flow of offline content data for the current experience.
The audio synchronization service, if available.
The service responsible for media playback functionalities.
The ID of the currently active global audio track.
The ID of the currently active video entity.
Starts playback that is synchronized with the audio sync service.
Begins playback without synchronization to the audio sync service.
Resumes playback from the current pause state.
Pauses the currently playing experience.
Stops the current playback entirely.
Mutes or unmutes the playback based on the isMute parameter. The isManualMute indicates if the action was triggered manually.
Seeks the playback backward or forward by a specified amount of time in seconds.
Jumps to a specific time offset in the playback.
Switches the active global audio track based on the given entity ID.
Switches the active video track based on the provided entity ID.
Changes the active global audio track to the one identified by trackId.
Changes the active video track to the one identified by trackId.
Initiates validation of the current sync status.
Stops the ongoing sync validation process.
Begins playback of a live experience.
Seeks the playback while maintaining synchronization.
Restarts the current playback from the beginning.
Restarts the playback, reinitializing any necessary services.
Adjusts the playback speed. A speed value of 1 represents normal speed.
Changes the playback quality based on the specified height parameter.
initOrUpdateSyncTimeline(position: Double?, syncStartTimeMs: Long?, resyncThreshold: Double?, isResync: Boolean): Double?
Initializes or updates the synchronization timeline with optional parameters for position, start time, and resynchronization threshold.
Checks if synchronization functionalities are accessible.
Starts the synchronization process for the current playback.
Initiates a resynchronization process.
Stops the current synchronization process.
Retrieves the service for managing experience manifests.
Gets the current experience manifest data.
Observes changes to the experience manifest data.
Checks if the current experience manifest is empty.
Retrieves a flow of entities defined in the current experience manifest.
Gets a specific entity by its ID from the experience manifest.
Retrieves a flow of video tracks from the experience manifest.
Retrieves a flow of audio tracks from the experience manifest.
Retrieves a flow of global audio tracks from the experience manifest.
Gets a specific audio track by its ID from the experience manifest.
Gets a specific video track by its ID from the experience manifest.
Sets a listener to observe changes in the experience manifest.
Retrieves details about the current playback state.
Gets extended information about the current experience.
Retrieves a global audio track by its entity ID from the experience manifest.
Retrieves a video track by its entity ID from the experience manifest.
Adds a listener for playback experience events.
Adds a listener for synchronization events.
Terminates the experience playback service, cleaning up any resources and stopping all ongoing activities.
Ensure you call terminateExpPlaybackService upon exiting your application or when the service is not required to avoid unexpected behavior, crashes, or lag. This step is vital for releasing resources and maintaining your app's stability and performance.
This documentation outlines the core functionalities of the ExperiencePlaybackService interface, enabling developers to effectively manage and control multimedia playback experiences within their applications.
onDestroy(): This function should be called when the UI will close. It is used to release resources and stop any ongoing operations.
NwExpUI serves as a customizable interface to GUI Overlays. The communication with the web layer is done using methods to send and receive certain events and states. The class described in the section below wraps this functionality.
If you want to know more about the underlying system and the event system that is used to communicate between the native and web layer, you can find a more thorough explanation in the Event System chapter of the Web SDK.
The NwExpUI alone does not play any content. It needs to be rendered above a player or a playback system like the NativeWaves Core.
Here's an overview of the NwExpUI interface: nativeToWebActions: A lazy-initialized instance of NativeToWebActions interface. This instance converts the action type and payload into a JavaScript function call and executes this JavaScript in the WebView. Logging is also done to track the JavaScript function call.
nativeToWeb(actions: NativeToWebActions): This function takes a NativeToWebActions object as a parameter and sends it to the WebView. If the WebView overlay is initialized, it directly sends the actions to WebView. Otherwise, it adds the actions to a waiting list _waitingListedActions to be sent later.
JSInterfaceActions: A lazy-initialized instance of JSInterfaceActions. This instance provides callbacks for various JavaScript-related operations such as asking for permissions, handling native to web actions, managing core SDK, volume, playback, etc. It also handles operations like GUI readiness, manual mute, and sync status. It also takes care of actions to be taken when the WebView overlay is initialized like sending waiting list actions to WebView and starting the WebView experience.
volumeObserver: A lazily initialized observer that responds to changes in system volume settings, invoking a function to handle volume-related actions and updates in the application.