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 queue ended Trigger twice #1243

Closed
mzyisbest opened this issue Aug 25, 2021 · 6 comments
Closed

Playback queue ended Trigger twice #1243

mzyisbest opened this issue Aug 25, 2021 · 6 comments
Labels

Comments

@mzyisbest
Copy link

Describe the bug
"Playback queue ended" monitoring is always called twice in a row, and each time it is the penultimate in my playback queue. It will be triggered after playing. Personally, I think it should be triggered after playing the last one

To Reproduce
Steps to reproduce the behavior:

Environment (please complete the following information):
react-native-track-player 2.0.3

Code
TrackPlayer.addEventListener('playback-queue-ended', async () => {
const queue = await TrackPlayer.getQueue();
const id = await TrackPlayer.getCurrentTrack();
console.log('******** remote-ended ********', id, queue);
if (queue && queue.length - 1 == id) {
await Player.next();
}
});

@mzyisbest
Copy link
Author

only in iphone. android is OK

@hiroyaiizuka
Copy link

same problem +1

@dcvz
Copy link
Contributor

dcvz commented Aug 31, 2021

It should definitely be triggered after playing the last item, this sounds like a bug.
Thanks for reporting @mzyisbest - we'll look into it!

@NguyenHoangNhatPhi
Copy link

You can use lodash/debounce to fix this one.

const handlePlaybackQueueEndedDebounce = debounce(function(){

// to do something

},500)

@bradfloodx
Copy link
Collaborator

Resolved but we can continue the conversation in #1349

@mmmoussa
Copy link
Contributor

mmmoussa commented Mar 1, 2022

I am currently using v2.2.0-rc2 which includes this fix but I am still seeing the event get fired twice on iOS: once upon reaching the last track and once when the queue has actually ended. This is the exact same bug I was experiencing with v2.1.2 before I upgraded.

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

6 participants