Skip to content
Snippets Groups Projects
Commit 7b25c892 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Geoffrey Métais
Browse files

Prevent PlaybackService loading notification bug

Fixes #1354
parent 9e1c2091
No related branches found
No related tags found
1 merge request!619Prevent PlaybackService loading notification bug
Pipeline #17907 passed with stage
in 17 minutes and 44 seconds
......@@ -457,9 +457,9 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
@RequiresApi(Build.VERSION_CODES.O)
override fun onCreate() {
dispatcher.onServicePreSuperOnCreate()
setupScope()
forceForeground()
super.onCreate()
setupScope()
NotificationHelper.createNotificationChannels(applicationContext)
settings = Settings.getInstance(this)
playlistManager = PlaylistManager(this)
......@@ -588,13 +588,13 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner {
private fun forceForeground() {
if (!AndroidUtil.isOOrLater || isForeground) return
val ctx = applicationContext
val stopped = PlayerController.playbackState == PlaybackStateCompat.STATE_STOPPED
val stopped = PlayerController.playbackState == PlaybackStateCompat.STATE_STOPPED || PlayerController.playbackState == PlaybackStateCompat.STATE_NONE
val notification = if (this::notification.isInitialized && !stopped) notification
else {
val pi = if (::playlistManager.isInitialized) sessionPendingIntent else null
NotificationHelper.createPlaybackNotification(ctx, false,
ctx.resources.getString(R.string.loading), "", "", null,
false, true, null, pi)
ctx.resources.getString(R.string.loading), "", "", null,
false, true, null, pi)
}
startForeground(3, notification)
isForeground = true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment