Merge pull request #4529 from ByteHamster/fix-queue-loader-thread

Load queue in background thread
This commit is contained in:
H. Lehmann 2020-10-16 09:27:10 +02:00 committed by GitHub
commit 545ac4eda0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -84,6 +84,7 @@ import io.reactivex.Observable;
import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
@ -315,7 +316,10 @@ public class PlaybackService extends MediaBrowserServiceCompat {
}
}
emitter.onSuccess(queueItems);
}).subscribe(queueItems -> mediaSession.setQueue(queueItems), Throwable::printStackTrace);
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(queueItems -> mediaSession.setQueue(queueItems), Throwable::printStackTrace);
flavorHelper.initializeMediaPlayer(PlaybackService.this);
mediaSession.setActive(true);