fix: offload image retrieval to Dispatchers.IO in PlayerService

- Replace `runBlocking(Main)` with `runBlocking(Dispatchers.IO)` in `getCurrentStationImage` and `getStationImageByUuid` to prevent potential UI thread blocking during file I/O.
This commit is contained in:
Michatec committed 2026-11-15 16:24:23 +01:00
1 parent cecb97f5a1
commit d744b777ec
1 file changed
+2 -2
@@ -280,7 +280,7 @@ class PlayerService : MediaLibraryService(), SharedPreferences.OnSharedPreferenc
}
override fun getCurrentStationImage(): ByteArray {
return runBlocking(Main) {
return runBlocking(Dispatchers.IO) {
val currentUuid = if (::player.isInitialized) {
player.currentMediaItem?.mediaId ?: PreferencesHelper.loadPlayerState().stationUuid
} else {
@@ -292,7 +292,7 @@ class PlayerService : MediaLibraryService(), SharedPreferences.OnSharedPreferenc
override fun getStationImageByUuid(uuid: String): ByteArray {
if (uuid.isEmpty()) return byteArrayOf()
val imageUri = runBlocking(Main) {
val imageUri = runBlocking(Dispatchers.IO) {
val imageFile = FileHelper.getStationImageFile(this@PlayerService, uuid)
if (imageFile.exists()) {
Uri.fromFile(imageFile).toString()