Support media resumption (#6350)
This fixes the disappearing media notification after pressing the play button.
This commit is contained in:
parent
2833812238
commit
9cd59a6720
@ -316,9 +316,14 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
public BrowserRoot onGetRoot(@NonNull String clientPackageName, int clientUid, Bundle rootHints) {
|
public BrowserRoot onGetRoot(@NonNull String clientPackageName, int clientUid, Bundle rootHints) {
|
||||||
Log.d(TAG, "OnGetRoot: clientPackageName=" + clientPackageName +
|
Log.d(TAG, "OnGetRoot: clientPackageName=" + clientPackageName +
|
||||||
"; clientUid=" + clientUid + " ; rootHints=" + rootHints);
|
"; clientUid=" + clientUid + " ; rootHints=" + rootHints);
|
||||||
return new BrowserRoot(
|
if (rootHints != null && rootHints.getBoolean(BrowserRoot.EXTRA_RECENT)) {
|
||||||
getResources().getString(R.string.app_name), // Name visible in Android Auto
|
Bundle extras = new Bundle();
|
||||||
null); // Bundle of optional extras
|
extras.putBoolean(BrowserRoot.EXTRA_RECENT, true);
|
||||||
|
return new BrowserRoot(getResources().getString(R.string.recently_played_episodes), extras);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name visible in Android Auto
|
||||||
|
return new BrowserRoot(getResources().getString(R.string.app_name), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadQueueForMediaSession() {
|
private void loadQueueForMediaSession() {
|
||||||
@ -392,8 +397,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<MediaBrowserCompat.MediaItem> loadChildrenSynchronous(@NonNull String parentId)
|
private List<MediaBrowserCompat.MediaItem> loadChildrenSynchronous(@NonNull String parentId) {
|
||||||
throws InterruptedException {
|
|
||||||
List<MediaBrowserCompat.MediaItem> mediaItems = new ArrayList<>();
|
List<MediaBrowserCompat.MediaItem> mediaItems = new ArrayList<>();
|
||||||
if (parentId.equals(getResources().getString(R.string.app_name))) {
|
if (parentId.equals(getResources().getString(R.string.app_name))) {
|
||||||
mediaItems.add(createBrowsableMediaItem(R.string.queue_label, R.drawable.ic_playlist_play_black,
|
mediaItems.add(createBrowsableMediaItem(R.string.queue_label, R.drawable.ic_playlist_play_black,
|
||||||
@ -421,6 +425,13 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
} else if (parentId.startsWith("FeedId:")) {
|
} else if (parentId.startsWith("FeedId:")) {
|
||||||
long feedId = Long.parseLong(parentId.split(":")[1]);
|
long feedId = Long.parseLong(parentId.split(":")[1]);
|
||||||
feedItems = DBReader.getFeedItemList(DBReader.getFeed(feedId));
|
feedItems = DBReader.getFeedItemList(DBReader.getFeed(feedId));
|
||||||
|
} else if (parentId.equals(getString(R.string.recently_played_episodes))) {
|
||||||
|
Playable playable = PlaybackPreferences.createInstanceFromPreferences(this);
|
||||||
|
if (playable instanceof FeedMedia) {
|
||||||
|
feedItems = Collections.singletonList(((FeedMedia) playable).getItem());
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Parent ID not found: " + parentId);
|
Log.e(TAG, "Parent ID not found: " + parentId);
|
||||||
return null;
|
return null;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
<string name="episode_cache_full_message">The episode cache limit has been reached. You can increase the cache size in the Settings.</string>
|
<string name="episode_cache_full_message">The episode cache limit has been reached. You can increase the cache size in the Settings.</string>
|
||||||
<string name="years_statistics_label">Years</string>
|
<string name="years_statistics_label">Years</string>
|
||||||
<string name="notification_pref_fragment">Notifications</string>
|
<string name="notification_pref_fragment">Notifications</string>
|
||||||
|
<string name="recently_played_episodes">Recently played episodes</string>
|
||||||
|
|
||||||
<!-- Google Assistant -->
|
<!-- Google Assistant -->
|
||||||
<string name="app_action_not_found">\"%1$s\" not found</string>
|
<string name="app_action_not_found">\"%1$s\" not found</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user