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

Playback screen on the lockscreen does not go away #16

Open
webmasterab opened this issue Aug 7, 2023 · 6 comments
Open

Playback screen on the lockscreen does not go away #16

webmasterab opened this issue Aug 7, 2023 · 6 comments

Comments

@webmasterab
Copy link

If I set the playbackstate to none, the screen doesn't go away.

lockscreen

I don't get this 'none' via a listener but via the setting of
this.playbackStopped = true;

And then calling this.updatePlaybackState();
This is the const converted to a function to use it that way.

Otherwise I don't even get the 'none' on the playBackstate

@webmasterab
Copy link
Author

Looks like I haven't processed it properly yet.

Because when I test it now, the screen is gone.

Please test on real device

@webmasterab
Copy link
Author

Unfortunately it does not work on a real device.

When I stop the player it stays on the lock screen.

No idea how I can fix this

@jofr
Copy link
Owner

jofr commented Jan 21, 2024

Is this still a problem? And is it a problem using a native Android app or using a web app on Android?

@jeremymouton
Copy link

What does your implementation look like? Wrapping setPlaybackState in an async/await fixed the issue for me.

@webmasterab
Copy link
Author

setPlaybackStatein

This is how I got this part.

updatePlaybackState() {

const playbackState = this.playbackStopped ? 'none' : (this.audio.paused ? 'paused' : 'playing');
MediaSession.setPlaybackState({
  playbackState: playbackState
});

}

@jeremymouton
Copy link

Try wrapping it in async/await, something like this:

async updatePlaybackState() {
  const playbackState = this.playbackStopped ? 'none' : (this.audio.paused ? 'paused' : 'playing');
  await MediaSession.setPlaybackState({
    playbackState: playbackState
  });
}

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

No branches or pull requests

3 participants