iOS SDK (Core)
Guides & Tutorials
14 min
the guides & tutorials section offers step by step instructions and practical examples for using the ios sdk custom overlay gui the ui layer of a nativewaves experience on android and ios is a web based layer that changes dynamically, based on the configuration done in the nativewaves console and the type of event you are watching by default, the url for the web layer is set by the app you can set your own url when initializing a new experienceviewcontroller the communication with the web layer is done using a nwexp interface which calls and receives certain events the interface is being described in the api reference docid\ ohvm1b05hdaxdbsuxqsqb playback & entity management this section will give an quick overview on how to control playback and handle entity (camera) changes accessing playback data the playback data can be accessed via the nwplaybackdelegate this example shows how to access the position of the playback by listening to the callback function in addition to just the position, this callback also contains information about duration, if the playback has ended, if the playback has video content available, if the playback is playing at the live edge and if the playback is playing at the synced position protocol nwplaybackdelegate { // called during playback to report playback progress func onplaybackprogress(position double, duration double, hasended bool, hasvideocontent bool, islive bool, issync bool?) } triggering an entity (camera) change the nwcore also provides a simple option to change the currently playing entity (camera) // set video entity experienceplaybackservice setselectedvideoentity(entityid string?) if you want to retrieve available entities first to provide the user a selection option, you can get them like this // get available video entities experienceplaybackservice getvideoentities() > \[nwentity]? to get the current selected entity, this can be done like this // get current selected video entityid experienceplaybackservice getselectedvideoentityid() > string? getting started with second screen sync to get started with the second screen sync, the recommended option is to use the directsync mode and try it with some vod content to enable the direct sync to e g sync against a vod event, you need to set the audiosyncmode to audiosyncmode library let syncservice = nwcore syncservice( , audiosyncmode library, ) additionally, you need to set a directsyncid , so the correct sync query is used let syncservice = nwcore syncservice( , directsyncid "\<direct sync id>", ) the directsyncid is created when sync information is extracted for vod events a common setup is to send the directsyncid as part of event information like the programid the next step is to initialize the sync and passing your optional delegate if you want to rececive sync callbacks syncservice delegate = self after everything is initialized and ready to go, simply start the sync by calling // start a sync experienceplaybackservice startsync() you can get the sync result by listening to the synchronizationoffsetfound callback, which contains the new offset identified by the sync // called when an offset was found func synchronizationoffsetfound(correlation mediaaudioquerymatch, syncstarttime double, isresync bool) // called on error func synchronizationerror( error nwerror) custom player integration if you want to implement an individual player logic, you can replace our preshipped player with your own to do so, you first need to add the customplayerdelegate to the experienceplaybackservice // let experienceplaybackservice = nwcore shared expviewcontroller( ) experienceplaybackservice customplayerdelegate = self you need to implement the nwcustomplayerdelegate protocol to inject your player whenever it's requested by the experienceplaybackservice the custom player needs to implement the nwplayer protocol in order to be compatible with our core engine func experienceplaybackservice( experienceplaybackservice nwexperienceplaybackservice, customplayerfor playbackobject nwplaybackobject) > nwplayer? { return customplayer(playbackobject playbackobject) } using a custom cdn if you want to use a particular cdn, the manifest needs to be configured properly right ahead that being given, you need to set a expconfigbaseurl which will be used to fetch the actual cdn config nwcore shared expconfigbaseurl = url(string "https //\<config> cdn nativewaves com/exp")! drm handling if you need to implement drm handling, there are two ways to exchange credentials both ways presume that you implement the nwcustomplayerdelegate and handle the async exchange function func experienceplaybackservice( experienceplaybackservice any nwexperienceplaybackservice, drmcredentialsfor drminfo nwdrminfo) async > nwdrmcredentials? { // 1 read drm key ids and provider ids from drminfo // 2 select which key pair should be used // 3 retrieve license info from your license server and return nwdrmcredentials } nwdrmcredentials struct nwdrmcredentials { var certificateurl url var licenseurl url } option 1 with our preshipped player , you still need to implement the customplayerfor method, but just return nil for the custom player func experienceplaybackservice( experienceplaybackservice nwexperienceplaybackservice, customplayerfor playbackobject nwplaybackobject) > nwplayer? { return nil } option 2 with your custom player used, everything stays the same as described in custom player integration