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

PlayerControlView enables (app disabled) play/pause button when controller layout is revealed on tap #2175

Open
1 task
Ethan1983 opened this issue Feb 21, 2025 · 2 comments
Assignees
Labels

Comments

@Ethan1983
Copy link

Version

Media3 main branch

More version details

main

Devices that reproduce the issue

Emulator

Devices that do not reproduce the issue

N/A

Reproducible in the demo app?

Yes

Reproduction steps

  1. Setup PlayerView to always disable play/pause button
playerView.findViewById(R.id.exo_play_pause).setEnabled(false);
playerView.findViewById(R.id.exo_play_pause).setAlpha(0.5f);
  1. Run the app and tap on the player view to reveal default controller

Expected result

Play/Pause button stays disabled as explicitly requested by the app

Actual result

Play/Pause button gets enabled automatically because of this code in PlayerControlView.

private void updatePlayPauseButton() {
      ...
      ...

      boolean enablePlayPause = Util.shouldEnablePlayPauseButton(player);
      updateButton(enablePlayPause, playPauseButton);
    }
  }

Media

N/A

Bug Report

  • You will email the zip file produced by adb bugreport to [email protected] after filing this issue.
@tonihei
Copy link
Collaborator

tonihei commented Feb 21, 2025

I'd say this is working as intended because PlayerControlView updates the state of the buttons according to the actual playback and this includes the whether the play button is enabled or not. You should be able to convince the player view that no play/pause command is supported by doing something like this instead:

playerView.setPlayer(new ForwardingSimpleBasePlayer(player) {
        @Override
        protected State getState() {
          State actualState = super.getState();
          return actualState.buildUpon()
              .setAvailableCommands(
                  actualState.availableCommands.buildUpon()
                      .remove(Player.COMMAND_PLAY_PAUSE)
                      .build())
              .build();
        }
      });

@tonihei tonihei self-assigned this Feb 21, 2025
@Ethan1983
Copy link
Author

I'd say this is working as intended because PlayerControlView updates the state of the buttons according to the actual playback and this includes the whether the play button is enabled or not. You should be able to convince the player view that no play/pause command is supported by doing something like this instead:

playerView.setPlayer(new ForwardingSimpleBasePlayer(player) {
        @Override
        protected State getState() {
          State actualState = super.getState();
          return actualState.buildUpon()
              .setAvailableCommands(
                  actualState.availableCommands.buildUpon()
                      .remove(Player.COMMAND_PLAY_PAUSE)
                      .build())
              .build();
        }
      });

Thanks. Play/Pause always being disabled was just to demonstrate. In our actual app, it is disabled only during a phone call. ExoPlayer handles audio focus and it pauses playback automatically. During the call, we would like to disable play/pause button. The default behaviour updatePlayPauseButton breaks this.

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

No branches or pull requests

2 participants