Key Examples

Last Updated on : 2024-06-18 08:04:14download

The Smart Lock SDK provides live streaming and two-way talk features for Wi-Fi locks.

Live streaming and two-way talk

Demo Class Method Description
IIPCManager void startPreview(int definition, IResultCallback callback); Start live streaming.
IIPCManager void stopPreview(IResultCallback callback); Stop live streaming.
IIPCManager void startTalk(IResultCallback callback);
void stopTalk(IResultCallback callback);
Turn on/off two-way talk.

When a feature is not in use, call the corresponding onDestroy method to prevent program errors.

Example

Live streaming request

val iThingLockManager = ThingOptimusSdk.getManager(IThingLockManager::class.java)
val iVideoLockManager = iThingLockManager.newVideoLockManagerInstance(mDevId)
//Start previewing
iVideoLockManager.ipcManager.startPreview(2, object : IResultCallback {
 override fun onSuccess() {
  showToast("startPreview success")
}

override fun onError(code: String?, error: String?) {
  showToast("startPreview error")
}
})

//Stop previewing
iVideoLockManager.ipcManager.stopPreview(object : IResultCallback {
override fun onSuccess() {
      showToast("stopPreview success")
}

override fun onError(code: String?, error: String?) {
      showToast("stopPreview error")
}
})

Two-way talk request

//Start talk
if(ipcManager.isSupportTalk && !ipcManager.isTalkBacking){
   ipcManager.startTalk(object : IResultCallback {
   override fun onSuccess() {
     showToast("startTalk success")
   }

   override fun onError(code: String?, error: String?) {
     showToast("startTalk error")
   }
   })
}
//Stop talk
iVideoLockManager.ipcManager.stopTalk(object : IResultCallback {
    override fun onSuccess() {
  showToast("stopTalk success")
}

    override fun onError(code: String?, error: String?) {
  showToast("stopTalk error")
}
})