From 2664292993e731012ec351a823cd1203aafbaff5 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Fri, 21 Jul 2023 17:08:56 -0400 Subject: [PATCH] Moves wake lock to activate only when the video is actually playing --- .../com/vitorpamplona/amethyst/MultiPlayerPlaybackManager.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/vitorpamplona/amethyst/MultiPlayerPlaybackManager.kt b/app/src/main/java/com/vitorpamplona/amethyst/MultiPlayerPlaybackManager.kt index f6ee5ad58..c2e069f0a 100644 --- a/app/src/main/java/com/vitorpamplona/amethyst/MultiPlayerPlaybackManager.kt +++ b/app/src/main/java/com/vitorpamplona/amethyst/MultiPlayerPlaybackManager.kt @@ -66,7 +66,6 @@ class MultiPlayerPlaybackManager( repeatMode = Player.REPEAT_MODE_ALL videoScalingMode = C.VIDEO_SCALING_MODE_SCALE_TO_FIT volume = 0f - setWakeMode(C.WAKE_MODE_NETWORK) } val mediaSession = MediaSession.Builder(context, player).run { @@ -80,8 +79,10 @@ class MultiPlayerPlaybackManager( player.addListener(object : Player.Listener { override fun onIsPlayingChanged(isPlaying: Boolean) { if (isPlaying) { + player.setWakeMode(C.WAKE_MODE_NETWORK) playingMap.put(id, mediaSession) } else { + player.setWakeMode(C.WAKE_MODE_NONE) cache.put(id, mediaSession) playingMap.remove(id, mediaSession) }