Skip to content

Commit 19cade4

Browse files
committed
Stop player when switching apps or screen off, don't auto-resume when returning
1 parent 6231c12 commit 19cade4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

app/src/main/java/com/pira/ccloud/VideoPlayerActivity.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,27 +261,30 @@ class VideoPlayerActivity : ComponentActivity() {
261261
// Ignore fullscreen errors
262262
}
263263

264-
// Resume player when activity resumes
264+
// Player will remain paused until user manually starts it
265265
try {
266266
if (playerInitialized && exoPlayer != null) {
267-
exoPlayer?.playWhenReady = true
267+
// Keep player paused - let user manually start playback
268+
exoPlayer?.playWhenReady = false
268269
}
269270
} catch (e: Exception) {
270-
// Ignore player resume errors
271+
// Ignore player state errors
271272
}
272273
}
273274

274275
override fun onPause() {
275276
super.onPause()
276277
isActivityResumed = false
277278

278-
// Pause player when activity pauses
279+
// Stop player completely when activity pauses (app switch or screen off)
279280
try {
280281
if (playerInitialized && exoPlayer != null) {
281282
exoPlayer?.playWhenReady = false
283+
// Note: currentPosition is managed in the Composable scope
284+
// Player will remain paused until user manually starts it
282285
}
283286
} catch (e: Exception) {
284-
// Ignore player pause errors
287+
// Ignore player stop errors
285288
}
286289
}
287290
}

0 commit comments

Comments
 (0)