Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equivalent method to platform's MediaSessionManager.getActiveSessions ? #281

Open
spocky opened this issue Mar 24, 2023 · 2 comments
Open

Comments

@spocky
Copy link

spocky commented Mar 24, 2023

I'm developping a launcher that displays a "Now Playing" section.
For now, I'm using the platform Media Session (getActiveSessions along with addOnActiveSessionsChangedListener).

MediaSessionManager mm = (MediaSessionManager) this.getSystemService(Context.MEDIA_SESSION_SERVICE);
ComponentName componentName = new ComponentName(this, NotificationListener.class);
List<MediaController> controllers = mm.getActiveSessions(componentName)

I can then iterate on the controllers to decide what to display.

Is there a way of reaching the same goal using the media3 lib ?

I tried using SessionToken.getAllServiceTokens() and then build a MediaController for each of them, but not all media apps return service tokens in this method (for example Youtube is missing).

@marcbaechinger
Copy link
Contributor

Yeah, there are some rough edges still. Please see #171 also.

The sessions returned by getAllServiceTokens are only tokens from apps that are using a service. Without knowing, it looks like YT probably doesn't use a service on this device which sounds plausible for a TV environment.

I think what you can do is convert the token to a Media3 session token with SessionToken.createSessionToken(Context context, MediaSessionCompat.Token compatToken) and then build a MediaController with it.

Please let us know if you find some further use cases that do not yet seamlessly work in this area, so we can collect this and then fix for a future release.

@steven0129
Copy link

Same Issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants