From a4760b64ee82569544f3af1cd2570fd4092dff37 Mon Sep 17 00:00:00 2001 From: Haggai Eran Date: Sun, 25 Dec 2022 09:16:43 +0200 Subject: [PATCH] Simple playback status and controls in Android Auto Expose a MediaBrowserService from within the existing PlayerService, and use the existing MediaSession for Auto. Empty media browser for now. To test, one needs to enable "Unknown sources" in Android Auto's developer settings. Issue: #1758 --- app/src/main/AndroidManifest.xml | 5 ++- .../schabi/newpipe/player/PlayerService.java | 41 ++++++++++++++++++- .../mediasession/MediaSessionPlayerUi.java | 1 + 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c7efcc9dbf2..3208849eb82 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -47,11 +47,14 @@ + + + > result) { + Log.w(TAG, "MediaBrowserService.onLoadChildren(%s)".format(parentId)); + + final List mediaItems = new ArrayList(); + + result.sendResult(mediaItems); + } } diff --git a/app/src/main/java/org/schabi/newpipe/player/mediasession/MediaSessionPlayerUi.java b/app/src/main/java/org/schabi/newpipe/player/mediasession/MediaSessionPlayerUi.java index e9541ab06d8..d7ce59078b3 100644 --- a/app/src/main/java/org/schabi/newpipe/player/mediasession/MediaSessionPlayerUi.java +++ b/app/src/main/java/org/schabi/newpipe/player/mediasession/MediaSessionPlayerUi.java @@ -40,6 +40,7 @@ public void initPlayer() { mediaSession = new MediaSessionCompat(context, TAG); mediaSession.setActive(true); + player.getService().setSessionToken(mediaSession.getSessionToken()); sessionConnector = new MediaSessionConnector(mediaSession); sessionConnector.setQueueNavigator(new PlayQueueNavigator(mediaSession, player));