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

onIsPlayingChanged not called when casting #9792

Closed
mikescamell opened this issue Dec 17, 2021 · 1 comment
Closed

onIsPlayingChanged not called when casting #9792

mikescamell opened this issue Dec 17, 2021 · 1 comment
Assignees
Labels

Comments

@mikescamell
Copy link

Hi I'm trying to implement the cast extension in our app but I'm having some issues with callbacks.

When casting using the ExoPlayer cast extension, pausing and playing the onIsPlayingChanged() callback does not called.

To reproduce

  • Add this block of code to the PlayerManager
    @Override
    public void onIsPlayingChanged(boolean isPlaying) {
        if (isPlaying) {
            Log.d("isPlaying","Is playing");
        } else {
            Log.d("isPlaying","Is not playing");
        }
    }
  • Load the demo and play some content
  • Cast
  • Play/Pause content repeatedly

Expected: The onIsPlayingChanged() callback i called with the correct playing state
Actual: The onIsPlayingChanged() is never called

I have noticed onPlayWhenReadyChanged() does get called but we already use onIsPlayingChanged()

  • ExoPlayer version number: 2.16.1
@marcbaechinger
Copy link
Contributor

I can confirm this behaviour. We will provide a fix for this. Thanks for reporting!

tonihei pushed a commit that referenced this issue Jan 4, 2022
Before this change we checked whether the playback state and playWhenReady have changed when the state from the cast device arrived. If we detected such a change we called the listener callback `onIsPlayingChanged`. However, in the case when `setPlayWhenReady(boolean)` is called on 'CastPlayer', we mask the change in `playWhenReady`, then send the play/pause request to the cast device and when the state from the cast device arrives we never detect a change because we have already masked `playWhenReady`.

This change now moves the check for `isPlaying` to the same place where the state and playWhenReady is updated, so we call the `onIsPlayingChanged` callback in either case, when masking or when a changed state from the server arrives.

Issue: #9792
PiperOrigin-RevId: 418483509
tonihei pushed a commit to androidx/media that referenced this issue Jan 5, 2022
Before this change we checked whether the playback state and playWhenReady have changed when the state from the cast device arrived. If we detected such a change we called the listener callback `onIsPlayingChanged`. However, in the case when `setPlayWhenReady(boolean)` is called on 'CastPlayer', we mask the change in `playWhenReady`, then send the play/pause request to the cast device and when the state from the cast device arrives we never detect a change because we have already masked `playWhenReady`.

This change now moves the check for `isPlaying` to the same place where the state and playWhenReady is updated, so we call the `onIsPlayingChanged` callback in either case, when masking or when a changed state from the server arrives.

Issue: google/ExoPlayer#9792
PiperOrigin-RevId: 418483509
@google google locked and limited conversation to collaborators Mar 28, 2022
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