mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
fix: background service audio playback when screen locked (#5142)
This commit is contained in:
parent
fca9aed07d
commit
981890acb9
@ -14,7 +14,10 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<application
|
||||
android:name=".LibreTubeApp"
|
||||
@ -350,16 +353,19 @@
|
||||
|
||||
<service
|
||||
android:name=".services.DownloadService"
|
||||
android:foregroundServiceType="dataSync"
|
||||
android:enabled="true"
|
||||
android:exported="false" />
|
||||
|
||||
<service
|
||||
android:name=".services.OnlinePlayerService"
|
||||
android:foregroundServiceType="mediaPlayback"
|
||||
android:enabled="true"
|
||||
android:exported="false" />
|
||||
|
||||
<service
|
||||
android:name=".services.OfflinePlayerService"
|
||||
android:foregroundServiceType="mediaPlayback"
|
||||
android:enabled="true"
|
||||
android:exported="false" />
|
||||
|
||||
|
@ -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 }
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user