Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import dji.v5.manager.datacenter.livestream.settings.RtspSettings
import dji.v5.manager.interfaces.ICameraStreamManager
import dji.v5.utils.common.ContextUtil
import dji.v5.utils.common.DjiSharedPreferencesManager
import java.lang.ref.WeakReference

/**
* ClassName : LiveStreamVM
Expand Down Expand Up @@ -69,10 +70,11 @@ class LiveStreamVM : DJIViewModel() {
}

fun startStream(callback: CommonCallbacks.CompletionCallback?) {
val weakReference = WeakReference(this)
streamManager.startStream(object : CommonCallbacks.CompletionCallback {
override fun onSuccess() {
CallbackUtils.onSuccess(callback)
reset();
weakReference.get()?.reset()
}

override fun onFailure(error: IDJIError) {
Expand All @@ -83,10 +85,11 @@ class LiveStreamVM : DJIViewModel() {
}

fun stopStream(callback: CommonCallbacks.CompletionCallback?) {
val weakReference = WeakReference(this)
streamManager.stopStream(object : CommonCallbacks.CompletionCallback {
override fun onSuccess() {
CallbackUtils.onSuccess(callback)
reset();
weakReference.get()?.reset()
}

override fun onFailure(error: IDJIError) {
Expand Down