Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
stop screencast when app killed on android
Browse files Browse the repository at this point in the history
  • Loading branch information
karkakol committed Apr 25, 2024
1 parent 482a07f commit c8df1a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 7 additions & 4 deletions android/src/main/java/com/reactnativemembrane/MembraneWebRTC.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class MembraneWebRTC(val sendEvent: (name: String, data: Map<String, Any?>) -> U
}

fun onDestroy() {
audioSwitchManager?.stop()
audioSwitchManager?.stop()
}

fun onActivityResult(
Expand Down Expand Up @@ -225,7 +225,7 @@ class MembraneWebRTC(val sendEvent: (name: String, data: Map<String, Any?>) -> U
fun disconnect() {
ensureCreated()
if (isScreencastOn) {
stopScreencast()
stopScreencast(false)
}
membraneRTC?.disconnect()
membraneRTC = null
Expand Down Expand Up @@ -652,15 +652,18 @@ class MembraneWebRTC(val sendEvent: (name: String, data: Map<String, Any?>) -> U
emitEndpoints()
}

private fun stopScreencast() {
private fun stopScreencast(calledFromToggleScreencast: Boolean = true) {
ensureScreencastTrack()
localScreencastTrack?.let {
removeTrackFromLocalEndpoint(it)
localScreencastTrack = null
}

setScreencastTrackState(false)
screencastPromise?.resolve(isScreencastOn)
if(calledFromToggleScreencast){
screencastPromise?.resolve(isScreencastOn)
}

screencastPromise = null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,5 +280,9 @@ class MembraneWebRTCModule : Module() {
OnDestroy {
membraneWebRTC.onDestroy()
}

OnActivityDestroys{
membraneWebRTC.disconnect()
}
}
}
}

0 comments on commit c8df1a2

Please sign in to comment.