diff options
author | Michael White <Michael.m.white@live.com> | 2020-04-21 10:04:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-21 16:04:03 +0200 |
commit | 3a86745e8144baa6d0a2cdc88aa0e29d1fd6e66c (patch) | |
tree | 7b448b028ea7e1ad040f6761d78a369c37da30cc /core/src | |
parent | c8790336b7884137ae125eaeeb66e620bca4bd96 (diff) | |
download | AntennaPod-3a86745e8144baa6d0a2cdc88aa0e29d1fd6e66c.zip |
added media to queue when playing (#4058)
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java index bd0315298..2679a93d4 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/playback/PlaybackService.java @@ -497,6 +497,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { return Service.START_NOT_STICKY; } mediaPlayer.playMediaObject(playable, stream, startWhenPrepared, prepareImmediately); + addPlayableToQueue(playable); } else { Log.d(TAG, "Did not handle intent to PlaybackService: " + intent); Log.d(TAG, "Extras: " + intent.getExtras()); @@ -652,6 +653,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { mediaPlayer.playMediaObject(playable, PlaybackPreferences.getCurrentEpisodeIsStream(), true, true); stateManager.validStartCommandWasReceived(); PlaybackService.this.updateMediaSessionMetadata(playable); + addPlayableToQueue(playable); } else { stateManager.stopService(); } @@ -1636,6 +1638,13 @@ public class PlaybackService extends MediaBrowserServiceCompat { } } + private void addPlayableToQueue(Playable playable) { + if (playable instanceof FeedMedia) { + long itemId = ((FeedMedia) playable).getId(); + DBWriter.addQueueItem(this, false, false, itemId); + } + } + private final MediaSessionCompat.Callback sessionCallback = new MediaSessionCompat.Callback() { private static final String TAG = "MediaSessionCompat"; @@ -1658,6 +1667,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { FeedMedia p = DBReader.getFeedMedia(Long.parseLong(mediaId)); if (p != null) { mediaPlayer.playMediaObject(p, !p.localFileAvailable(), true, true); + addPlayableToQueue(p); } } @@ -1669,6 +1679,7 @@ public class PlaybackService extends MediaBrowserServiceCompat { if (results.size() > 0 && results.get(0).getMedia() != null) { FeedMedia media = results.get(0).getMedia(); mediaPlayer.playMediaObject(media, !media.localFileAvailable(), true, true); + addPlayableToQueue(media); return; } onPlay(); |