diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 41d01e6a4..6b386c177 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,7 +14,10 @@ + + + diff --git a/app/src/main/java/com/github/libretube/services/OfflinePlayerService.kt b/app/src/main/java/com/github/libretube/services/OfflinePlayerService.kt index 7dd64acaf..fd56c12b8 100644 --- a/app/src/main/java/com/github/libretube/services/OfflinePlayerService.kt +++ b/app/src/main/java/com/github/libretube/services/OfflinePlayerService.kt @@ -86,6 +86,8 @@ class OfflinePlayerService : LifecycleService() { } player = PlayerHelper.createPlayer(this, trackSelector, true) + // prevent android from putting LibreTube to sleep when locked + player!!.setWakeMode(C.WAKE_MODE_LOCAL) val audioItem = downloadWithItem.downloadItems.filter { it.path.exists() } .firstOrNull { it.type == FileType.AUDIO } diff --git a/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt b/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt index 3919055fc..f2b755588 100644 --- a/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt +++ b/app/src/main/java/com/github/libretube/services/OnlinePlayerService.kt @@ -13,6 +13,7 @@ import androidx.core.net.toUri import androidx.lifecycle.LifecycleService import androidx.lifecycle.lifecycleScope import androidx.media3.common.C +import androidx.media3.common.C.WAKE_MODE_NETWORK import androidx.media3.common.MediaItem import androidx.media3.common.MimeTypes import androidx.media3.common.PlaybackException @@ -247,6 +248,8 @@ class OnlinePlayerService : LifecycleService() { } player = PlayerHelper.createPlayer(this, trackSelector, true) + // prevent android from putting LibreTube to sleep when locked + player!!.setWakeMode(WAKE_MODE_NETWORK) /** * Listens for changed playbackStates (e.g. pause, end)