diff --git a/app/src/main/kotlin/it/vfsfitvnm/vimusic/services/PlayerService.kt b/app/src/main/kotlin/it/vfsfitvnm/vimusic/services/PlayerService.kt index ce262a7..37991bb 100644 --- a/app/src/main/kotlin/it/vfsfitvnm/vimusic/services/PlayerService.kt +++ b/app/src/main/kotlin/it/vfsfitvnm/vimusic/services/PlayerService.kt @@ -64,15 +64,11 @@ class PlayerService : MediaSessionService(), MediaSession.MediaItemFiller, private const val NotificationChannelId = "default_channel_id" } - private val cache: SimpleCache by lazy(LazyThreadSafetyMode.NONE) { - SimpleCache(cacheDir, NoOpCacheEvictor(), StandaloneDatabaseProvider(this)) - } + private lateinit var cache: SimpleCache private lateinit var mediaSession: MediaSession - private val notificationManager by lazy(LazyThreadSafetyMode.NONE) { - getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager - } + private lateinit var notificationManager: NotificationManager private var lastArtworkUri: Uri? = null private var lastBitmap: Bitmap? = null @@ -87,6 +83,8 @@ class PlayerService : MediaSessionService(), MediaSession.MediaItemFiller, createNotificationChannel() setMediaNotificationProvider(this) + cache = SimpleCache(cacheDir, NoOpCacheEvictor(), StandaloneDatabaseProvider(this)) + val player = ExoPlayer.Builder(this) .setHandleAudioBecomingNoisy(true) .setWakeMode(C.WAKE_MODE_LOCAL) @@ -351,6 +349,7 @@ class PlayerService : MediaSessionService(), MediaSession.MediaItemFiller, ) = Unit private fun createNotificationChannel() { + notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager if (Util.SDK_INT >= 26 && notificationManager.getNotificationChannel(NotificationChannelId) == null) { notificationManager.createNotificationChannel( NotificationChannel(