question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide a way to dynamically enable/disable seeking

See original GitHub issue

I am using DAI with ExoPlayer and IMA.

As you can see from the video…when an Ad is playing I can scrub on TimeBar even though I call setEnabled(false) on it. From the DefaultTimeBar implementation,

 @Override
  public void setEnabled(boolean enabled) {
    super.setEnabled(enabled);
    if (scrubbing && !enabled) {
      stopScrubbing(/* canceled= */ true);
    }
  }

scrubbing flag prevents TimeBar to stop scrubbing.

I would like to achieve no scrubbing on the time bar. What should I do?

https://user-images.githubusercontent.com/32653955/115424499-c37bc180-a1cc-11eb-9dbd-3227aa024a86.mp4

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kim-vdecommented, Sep 7, 2021

Yes.

To disable seekbar scrubbing, you can make command COMMAND_SEEK_IN_CURRENT_WINDOW unavailable by wrapping the player passed to the (Styled)PlayerView in a ForwardingPlayer:

ForwardingPlayer forwardingPlayer =
    new ForwardingPlayer(player) {
      @Override
      public boolean isCommandAvailable(int command) {
        if (command == COMMAND_SEEK_IN_CURRENT_WINDOW) {
          return false;
        }
        return super.isCommandAvailable(command);
      }

      @Override
      public Commands getAvailableCommands() {
        return super.getAvailableCommands()
            .buildUpon()
            .remove(COMMAND_SEEK_IN_CURRENT_WINDOW)
            .build();
      }
    };
playerView.setPlayer(forwardingPlayer);
1reaction
ojw28commented, Apr 20, 2021

Is that a modified version of the IMA-DAI example? I tried with the official version available here, and I did not see the problematic behaviour because they hide the controller whilst ads are playing.

Digging around with ((DefaultTimeBar)activity.findViewById(R.id.exo_progress)).setEnabled(canSeek); isn’t going to work, because PlayerControlView that owns the DefaultTimeBar is also calling setEnabled on the same view. It does this based on whether the media content being played is seekable, which it is.

I don’t think there is a good way of disabling scrubbing at the UI level currently, when using PlayerView or PlayerControlView. You’d probably have to fork the UI components and edit them directly to get exactly what you want. That said, this more or less works as a hack:

public void setCanSeek(boolean canSeek) {
  this.canSeek = canSeek;
  if (canSeek) {
    ((DefaultTimeBar) activity.findViewById(R.id.exo_progress)).showScrubber();
  } else {
    ((DefaultTimeBar) activity.findViewById(R.id.exo_progress)).hideScrubber(false);
  }
}

We’re currently working on changes that will allow the player to specify which commands are currently enabled for use, that the UI components will query. We will also provide a ForwardingPlayer that makes it easy to disable commands that the underlying player would otherwise indicate as being available. This will provide a good solution to this problem. I’ll leave it open as an enhancement to track implementing this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set Dynamic enable/disable for ... - Stack Overflow
In HTML Just add disabled="disabled" as an attribute to disable and checked="checked" as attribute to checked as default.
Read more >
How to enable and disable a field dynamically
I need to use PowerApps due to I want that some input elements will be "dynamic". In my case I have a combo...
Read more >
dynamically/programatically enable/disable plugin?
Hello, I have a scheduled job that I need to run nightly. This job requires that one of the plugin entities be disabled...
Read more >
How can i dynamically disable/enable sessions during ...
1) Check If a session succeeds, i want to disable it dynamically,. 2) Check if the workflow has suceeded then i want to...
Read more >
Enable/ disable jobs in stage dynamically?
Is there a way to enable or disable job dynamically in runtime in Bamboo just like conditional tasks? Answer · Watch.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found