Skip to content

Commit 2a8ddcf

Browse files
committed
fix screen app example
1 parent 6180827 commit 2a8ddcf

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

app/src/main/java/com/pedro/streamer/screen/ScreenActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class ScreenActivity : AppCompatActivity(), ConnectChecker {
198198
screenService.setCallback(null)
199199
activityResultContract.unregister()
200200
//stop service only if no streaming or recording
201-
stopService(Intent(this, ScreenService::class.java))
201+
if (isFinishing) stopService(Intent(this, ScreenService::class.java))
202202
}
203203
}
204204

app/src/main/java/com/pedro/streamer/screen/ScreenService.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,14 @@ class ScreenService: Service(), ConnectChecker {
161161
this.mediaProjection = mediaProjection
162162
val screenSource = ScreenSource(applicationContext, mediaProjection)
163163
return try {
164+
genericStream.changeVideoSource(screenSource)
164165
//ScreenSource need use always setCameraOrientation(0) because the MediaProjection handle orientation.
165166
//You also need remove autoHandleOrientation if you are using it.
166167
//You need to call it after prepareVideo to override the default value.
168+
//Remember call is after changeVideoSource because that method call to setCameraOrientation and produce problems
169+
val isPortrait = rotation == 90 || rotation == 270
170+
genericStream.getGlInterface().setIsPortrait(isPortrait)
167171
genericStream.getGlInterface().setCameraOrientation(0)
168-
genericStream.changeVideoSource(screenSource)
169172
toggleAudioSource(selectedAudioSource)
170173
true
171174
} catch (ignored: IllegalArgumentException) {

0 commit comments

Comments
 (0)