mirror of
https://github.com/Michatec/Radio.git
synced 2026-11-16 08:11:38 +01:00
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:
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()
|
||||
|
||||
Reference in new issue
Block a user