Load queue in background thread

This commit is contained in:
ByteHamster 2020-10-14 20:26:47 +02:00
parent e9fa84af58
commit dc7e2bebbb
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);