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

How can I remove player commands of the platform mediasession? #542

Open
darrentaft opened this issue Jul 25, 2023 · 5 comments
Open

How can I remove player commands of the platform mediasession? #542

darrentaft opened this issue Jul 25, 2023 · 5 comments
Assignees

Comments

@darrentaft
Copy link

We offer live DASH streams within our app. We're using our own custom player controls, so have full control over what the user can do - i.e. when it's on-demand content we allow them to seek/pause/skip/etc, but when it's live they can only stop the stream.

With the standard integration of Media3 into MediaSession, we're finding that the Picture-In-Picture window is automatically offering player controls. This is great for on-demand content, but for our live streams we don't want the user being able to pause or seek the stream (as there's only a 44 second seekable window).

I can see a "setAvailableCommands" option on the MediaSession, however I can't work out where to get the additional "controller" and "sessionCommands" parameters from. I tried using the listener onConnect() approach, but it had no effect.

Google hasn't helped me find any suitable answers - either for Media3, or for ExoPlayer.

@oceanjules
Copy link
Contributor

How about:

/** Returns the list of connected controllers. */
public final List<ControllerInfo> getConnectedControllers() {
return impl.getConnectedControllers();
}

@tonihei
Copy link
Collaborator

tonihei commented Jul 26, 2023

I tried using the listener onConnect() approach, but it had no effect.

Ideally, the case you described should be handled in this method. @marcbaechinger Am I right in assuming that this is the problem you are currently addressing by moving the channeling the legacy controller through our internal Media3 controller? If so, we can use this issue to track this enhancement (or duplicate it if there already is one).

@darrentaft: As a workaround, you can wrap you player in a ForwardingPlayer when giving it to the MediaSession.Builder. And then override getAvailableCommands and isCommandAvailable to filter the available commands from your player.

@tonihei tonihei assigned tonihei and marcbaechinger and unassigned tonihei Jul 26, 2023
@marcbaechinger marcbaechinger changed the title How can I remove trickplay commands from a live stream mediasession? How can I remove player commands of the platform mediasession? Jul 26, 2023
@marcbaechinger
Copy link
Contributor

I'm not super-familiar with PiP, but I assume that Picture-in-Picture is connected to the platform session.

But yes, using a ForwardingPlayer as @tonihei suggested is the solution for now. There will be another approach for this soon that allows to set the available commands through a controller which then only affects the available player commands of the platform session. The ForwardingPlayer approach has the disadvantage that other Media3 controllers see the same restricted available player commands.

but for our live streams we don't want the user being able to pause or seek the stream

The mentioned approach would then also handle this for the notification for which I assume, the controls should be hidden for live in the same way.

I'll mark this issue as an enhancement to track the change we are talking about.

@darrentaft
Copy link
Author

That's great, thanks - I can confirm that ForwardingPlayer removes the play/pause button (although bizarrely it only disables the skip back/forward buttons, rather than removing them). That's good enough for now though.

@marcbaechinger
Copy link
Contributor

I think the button being disabled only may be the problem we have for Auto as well and is described in #339
The UI reflects the platform media session with a queue of a single item. Instead we need to provide a way to have the queue empty. I guess/believe then the next/prev buttons wouldn't show up.

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

4 participants