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

Private constructor in DefaultMediaNotificationProvider makes overriding impossible #213

Closed
tzugen opened this issue Nov 27, 2022 · 2 comments
Assignees
Labels

Comments

@tzugen
Copy link

tzugen commented Nov 27, 2022

Media3 Version

1.0.0-beta03

Reproduction steps

In getMediaButtons the comment reads:

Override this method to customize the buttons on the notification. Commands of the buttons returned by this method must be contained in MediaController.getAvailableCommands().

Unfortunately it seems to be impossible to extend DefaultMediaNotificationProvider in beta-3, because Java will require a call to the constructor() of the inherited function, but it is private in DefaultMediaNotificationProvider.

Maybe there is some advanced trick to get it working, but it shouldn't not be that complicated, or at least documented how one can do it.

Full code:

@UnstableApi public class CustomProvider extends DefaultMediaNotificationProvider {
    public CustomProvider(Context ctx) {
        super(new Builder(ctx));
    }
    
    @Override
    protected List<CommandButton> getMediaButtons(Player.Commands playerCommands, List<CommandButton> customLayout, boolean showPauseButton) {
        return super.getMediaButtons(playerCommands, customLayout, showPauseButton);
    }
}
@tzugen tzugen changed the title Private constructor in DefaultMediaNotificationProvider makes overriding hard (or impossible) Private constructor in DefaultMediaNotificationProvider makes overriding impossible Nov 27, 2022
@rohitjoins rohitjoins self-assigned this Nov 28, 2022
@rohitjoins
Copy link
Contributor

rohitjoins commented Nov 28, 2022

Thank you for reporting this. We will soon push a fix in the main branch.

rohitjoins added a commit that referenced this issue Nov 29, 2022
Issue: #213

Without a public constructor, it is not possible to extend this class and override its method.

PiperOrigin-RevId: 491673111
@rohitjoins
Copy link
Contributor

A fix for this has been released to the main branch.

christosts pushed a commit that referenced this issue Jan 31, 2023
Issue: #213

Without a public constructor, it is not possible to extend this class and override its method.

PiperOrigin-RevId: 491673111
(cherry picked from commit f3e450e)
@androidx androidx locked and limited conversation to collaborators Mar 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants