Merge pull request #4199 from ByteHamster/playback-service-optimizations
Playback service optimizations
This commit is contained in:
commit
98a2567408
|
@ -79,6 +79,7 @@ import de.danoeh.antennapod.core.util.playback.ExternalMedia;
|
|||
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||
import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
@ -268,7 +269,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
|
||||
stateManager = new PlaybackServiceStateManager(this);
|
||||
notificationBuilder = new PlaybackServiceNotificationBuilder(this);
|
||||
stateManager.startForeground(R.id.notification_playing, notificationBuilder.build());
|
||||
|
||||
registerReceiver(autoStateUpdated, new IntentFilter("com.google.android.gms.car.media.STATUS"));
|
||||
registerReceiver(headsetDisconnected, new IntentFilter(Intent.ACTION_HEADSET_PLUG));
|
||||
|
@ -304,18 +304,16 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||
npe.printStackTrace();
|
||||
}
|
||||
|
||||
List<MediaSessionCompat.QueueItem> queueItems = new ArrayList<>();
|
||||
try {
|
||||
Single.<List<MediaSessionCompat.QueueItem>>create(emitter -> {
|
||||
List<MediaSessionCompat.QueueItem> queueItems = new ArrayList<>();
|
||||
for (FeedItem feedItem : taskManager.getQueue()) {
|
||||
if (feedItem.getMedia() != null) {
|
||||
MediaDescriptionCompat mediaDescription = feedItem.getMedia().getMediaItem().getDescription();
|
||||
queueItems.add(new MediaSessionCompat.QueueItem(mediaDescription, feedItem.getId()));
|
||||
}
|
||||
}
|
||||
mediaSession.setQueue(queueItems);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
emitter.onSuccess(queueItems);
|
||||
}).subscribe(queueItems -> mediaSession.setQueue(queueItems), Throwable::printStackTrace);
|
||||
|
||||
flavorHelper.initializeMediaPlayer(PlaybackService.this);
|
||||
mediaSession.setActive(true);
|
||||
|
|
|
@ -131,7 +131,7 @@ public class PlaybackServiceNotificationBuilder {
|
|||
}
|
||||
} else {
|
||||
notification.setContentTitle(context.getString(R.string.app_name));
|
||||
notification.setContentText("Service is running");
|
||||
notification.setContentText("Loading. If this does not go away, play any episode and contact us.");
|
||||
}
|
||||
|
||||
notification.setContentIntent(getPlayerActivityPendingIntent());
|
||||
|
|
Loading…
Reference in New Issue