Open webmasterab opened 1 year ago
Looks like I haven't processed it properly yet.
Because when I test it now, the screen is gone.
Please test on real device
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
Is this still a problem? And is it a problem using a native Android app or using a web app on Android?
What does your implementation look like? Wrapping setPlaybackState
in an async/await fixed the issue for me.
setPlaybackState
in
This is how I got this part.
updatePlaybackState() {
const playbackState = this.playbackStopped ? 'none' : (this.audio.paused ? 'paused' : 'playing');
MediaSession.setPlaybackState({
playbackState: playbackState
});
}
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
});
}
If I set the playbackstate to none, the screen doesn't go away.
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