Android SDK (Core)
Getting Started
8 min
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 initialize sdk the first step to initialize the sdk is to instantiate and initialize the nwcore private val nwcoresdk nwcore by lazy { nwcoreimpl builder(this) build() } 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 protected lateinit var nwcoresdk nwcore nwcoresdk = nwcoreimpl builder(this) build() nwcore can be initialized by using hilt like this @module @installin(singletoncomponent class) object basemodules { @provides fun providenwcoresdk(@applicationcontext context context) nwcore { return nwcoreimpl builder(context) build() } } @androidentrypoint class mainactivity() appcompatactivity() { @inject lateinit var nwcoresdk nwcore } 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 val scope = remembercoroutinescope() val expmanifestid string = "\<expmanifestid>" val overlayurl string = "\<overlayurl>" val expplayback = remember { mutablestateof\<experienceplaybackservice?>(null) } launchedeffect(unit) { scope launch { nwcoresdk run { environment = nwenvironment prod // optional locale = "en" // optional expplayback value = this experienceplaybackservice( expmanifestid = expmanifestid, audiosyncservice = null, ) } } } manifest identifiers expmanifestid a unique identifier for the experience manifest, essential for fetching the correct multimedia content gui overlay url an overlay url verlayurl ) 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 box( modifier = modifier fillmaxsize(), contentalignment = alignment center ) { nwcoresdk expcomposeview( context = this\@mainactivity, audiosynccallback = null, expplaybackservice = expplayback value!!, guioverlayurl = overlayurl, onerror = { timber e(it) }, oncustomaction = { timber d(it) }, exitplayback = { }, oncheckaudiopermission = { } ) } 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 integrate external exoplayer to terminate the nw exp services 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 implementation breakdown 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 docid\ iw3qlop9opptsdgmgjw z chapter