Android SDK (Core)

API Reference

78min

.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.

NwCore Interface Documentation

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.

Properties

appId: String: The unique identifier for the application.

Kotlin


environment: NwEnvironment: An instance that defines the operational environment settings.

Kotlin


locale: String: The current locale of the application, typically used for localization.

Kotlin


contentProviderUrl: String: The URL to the content provider that supplies media and experience data.

Kotlin


timelineSync: NwTimelineSync: An instance that handles synchronization with the timeline service.

Kotlin


isNwSDKInitialized: Boolean: A boolean flag indicating whether the SDK has been initialized.

Kotlin


Functions

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.

Kotlin


experiencePlaybackService(expManifestId: String, audioSyncService: AudioSyncService?): ExperiencePlaybackServiceCreates a playback service for a specific experience manifest, optionally using an audio synchronization service.

Kotlin


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.

Kotlin


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.

Kotlin


checkAudioPermission(isGranted: Boolean)Notifies the SDK of the current audio permission state.

Kotlin


getVersionName(): StringReturns the version name of the SDK.

Kotlin


onDestroy()Cleans up resources and shuts down services when the instance is no longer needed.

Kotlin


Additional Components

  • @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.

Exception Handling

  • NwException: A custom exception type used for error handling within the SDK functions.

Usage Context

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.

ExperiencePlaybackService Interface Documentation

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.

Properties

scope: CoroutineScope

The coroutine scope associated with the playback service for managing asynchronous tasks.

Kotlin


expManifestId: String

The identifier of the current experience manifest.

Kotlin


isOfflineFileAvailable: Boolean

Indicates whether offline files are available for playback.

Kotlin


isLive: Boolean

Indicates if the current playback is a live experience.

Kotlin


isPlaybackMuted: Boolean

Reflects the current mute state of the playback.

Kotlin


isPlaying: Boolean

Indicates if playback is currently active.

Kotlin


isPrepared: Boolean

Shows whether the playback service is prepared to start playback.

Kotlin


isSynced: Boolean

Indicates whether the playback is synchronized with the audio sync service.

Kotlin


isCurrentlySynced: Boolean

Shows if the playback is currently in sync according to the latest checks.

Kotlin


offlineContent: StateFlow<OfflineContent>

A flow of offline content data for the current experience.

Kotlin


audioSyncService: AudioSyncService?

The audio synchronization service, if available.

Kotlin


mediaPlaybackService: MediaPlaybackService

The service responsible for media playback functionalities.

Kotlin


activeGlobalAudioTrackId: StateFlow<String>

The ID of the currently active global audio track.

Kotlin


activeVideoEntityId: StateFlow<String>

The ID of the currently active video entity.

Kotlin


Playback Control Functions

startSyncedPlayback()

Starts playback that is synchronized with the audio sync service.

Kotlin


startUnsyncedPlayback()

Begins playback without synchronization to the audio sync service.

Kotlin


resumePlayback()

Resumes playback from the current pause state.

Kotlin


pausePlayback()

Pauses the currently playing experience.

Kotlin


stopPlayback()

Stops the current playback entirely.

Kotlin


muteOrUnmutePlayback(isMute: Boolean, isManualMute: Boolean = false)

Mutes or unmutes the playback based on the isMute parameter. The isManualMute indicates if the action was triggered manually.

Kotlin


seekBackOrForward(backOrForward: Double)

Seeks the playback backward or forward by a specified amount of time in seconds.

Kotlin


jumpTo(seekOffset: Double)

Jumps to a specific time offset in the playback.

Kotlin


switchActiveGlobalAudioTrackByEntityId(entityId: String?)

Switches the active global audio track based on the given entity ID.

Kotlin


switchActiveVideoTrackByEntityId(entityId: String?)

Switches the active video track based on the provided entity ID.

Kotlin


switchActiveGlobalAudioTrack(trackId: String? = null)

Changes the active global audio track to the one identified by trackId.

Kotlin


switchActiveVideoTrack(trackId: String? = null)

Changes the active video track to the one identified by trackId.

Kotlin


startSyncValidation()

Initiates validation of the current sync status.

Kotlin


stopSyncValidation()

Stops the ongoing sync validation process.

Kotlin


startLivePlayback()

Begins playback of a live experience.

Kotlin


seekSyncedPlayback()

Seeks the playback while maintaining synchronization.

Kotlin


replayPlayback()

Restarts the current playback from the beginning.

Kotlin


restartPlayback()

Restarts the playback, reinitializing any necessary services.

Kotlin


changePlaybackSpeed(speed: Double)

Adjusts the playback speed. A speed value of 1 represents normal speed.

Kotlin


changeQuality(height: Int)

Changes the playback quality based on the specified height parameter.

Kotlin


Sync Functions

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.

Kotlin


isSyncAccessible(): Boolean

Checks if synchronization functionalities are accessible.

Kotlin


startSync()

Starts the synchronization process for the current playback.

Kotlin


startResync()

Initiates a resynchronization process.

Kotlin


stopSync()

Stops the current synchronization process.

Kotlin


Experience Manifest Handling

getExpManifestService(): ExpManifestService

Retrieves the service for managing experience manifests.

Kotlin


getExpManifest(): ExpManifestData

Gets the current experience manifest data.

Kotlin


getExpManifestObserver(): StateFlow<ExpManifestData>

Observes changes to the experience manifest data.

Kotlin


isExpManifestEmpty(): StateFlow<Boolean>

Checks if the current experience manifest is empty.

Kotlin


getEntities(): StateFlow<List<ExpManifestEntity>>

Retrieves a flow of entities defined in the current experience manifest.

Kotlin


getEntity(entityId: String?): ExpManifestEntity?

Gets a specific entity by its ID from the experience manifest.

Kotlin


getVideoTracks(): StateFlow<List<ExpManifestVideoTrack>>

Retrieves a flow of video tracks from the experience manifest.

Kotlin


getAudioTracks(): StateFlow<List<ExpManifestAudioTrack>>

Retrieves a flow of audio tracks from the experience manifest.

Kotlin


getGlobalAudioTracks(): StateFlow<List<ExpManifestGlobalAudioTrack>>

Retrieves a flow of global audio tracks from the experience manifest.

Kotlin


getAudioTrackById(trackId: String?): ExpManifestAudioTrack?

Gets a specific audio track by its ID from the experience manifest.

Kotlin


getVideoTrackById(trackId: String?): ExpManifestVideoTrack?

Gets a specific video track by its ID from the experience manifest.

Kotlin


setExpManifestListener(expManifestListener: ExpManifestListener?)

Sets a listener to observe changes in the experience manifest.

Kotlin


Playback Information Retrieval

getCurrentPlaybackDetails(): CurrentPlaybackDetails

Retrieves details about the current playback state.

Kotlin


getExpInfo(): CurrentPlaybackDetails?

Gets extended information about the current experience.

Kotlin


getGlobalAudioById(entityId: String?): ExpManifestGlobalAudioTrack?

Retrieves a global audio track by its entity ID from the experience manifest.

Kotlin


getVideoTrackByEntityId(entityId: String?): ExpManifestVideoTrack?

Retrieves a video track by its entity ID from the experience manifest.

Kotlin


Listener Management

addExperienceListener(playbackExperienceListener: PlaybackExperienceListener)

Adds a listener for playback experience events.

Kotlin


addSyncListener(syncListener: SyncListener)

Adds a listener for synchronization events.

Kotlin


Service Termination

terminateExpPlaybackService()

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.

Kotlin




This documentation outlines the core functionalities of the ExperiencePlaybackService interface, enabling developers to effectively manage and control multimedia playback experiences within their applications.

Lifecycle Management



onDestroy(): This function should be called when the UI will close. It is used to release resources and stop any ongoing operations.

Kotlin


NwExpUI

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.