diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 3e987abdbb0..df88a7890ce 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -56,6 +56,9 @@
+
+
+
> result) {
+ mediaBrowserConnector.onLoadChildren(parentId, result);
+ }
}
diff --git a/app/src/main/java/org/schabi/newpipe/player/mediabrowser/MediaBrowserConnector.java b/app/src/main/java/org/schabi/newpipe/player/mediabrowser/MediaBrowserConnector.java
index 6fc61c3d748..4a5952fce74 100644
--- a/app/src/main/java/org/schabi/newpipe/player/mediabrowser/MediaBrowserConnector.java
+++ b/app/src/main/java/org/schabi/newpipe/player/mediabrowser/MediaBrowserConnector.java
@@ -1,13 +1,23 @@
package org.schabi.newpipe.player.mediabrowser;
+import android.os.Bundle;
+import android.support.v4.media.MediaBrowserCompat;
+import android.support.v4.media.MediaBrowserCompat.MediaItem;
import android.support.v4.media.session.MediaSessionCompat;
+import android.util.Log;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.media.MediaBrowserServiceCompat;
+import androidx.media.MediaBrowserServiceCompat.Result;
import com.google.android.exoplayer2.ext.mediasession.MediaSessionConnector;
import org.schabi.newpipe.player.PlayerService;
+import java.util.ArrayList;
+import java.util.List;
+
public class MediaBrowserConnector {
private static final String TAG = MediaBrowserConnector.class.getSimpleName();
@@ -20,6 +30,7 @@ public MediaBrowserConnector(@NonNull final PlayerService playerService) {
mediaSession = new MediaSessionCompat(playerService, TAG);
sessionConnector = new MediaSessionConnector(mediaSession);
sessionConnector.setMetadataDeduplicationEnabled(true);
+ playerService.setSessionToken(mediaSession.getSessionToken());
}
public @NonNull MediaSessionConnector getSessionConnector() {
@@ -29,4 +40,26 @@ public MediaBrowserConnector(@NonNull final PlayerService playerService) {
public void release() {
mediaSession.release();
}
+
+ @NonNull
+ private static final String MY_MEDIA_ROOT_ID = "media_root_id";
+
+ @Nullable
+ public MediaBrowserServiceCompat.BrowserRoot onGetRoot(@NonNull final String clientPackageName,
+ final int clientUid,
+ @Nullable final Bundle rootHints) {
+ Log.d(TAG, String.format("MediaBrowserService.onGetRoot(%s, %s, %s)",
+ clientPackageName, clientUid, rootHints));
+
+ return new MediaBrowserServiceCompat.BrowserRoot(MY_MEDIA_ROOT_ID, null);
+ }
+
+ public void onLoadChildren(@NonNull final String parentId,
+ @NonNull final Result> result) {
+ Log.d(TAG, String.format("MediaBrowserService.onLoadChildren(%s)", parentId));
+
+ final List mediaItems = new ArrayList<>();
+
+ result.sendResult(mediaItems);
+ }
}