Boosting this. I'm using MusicKit and need to detect the end of the queue.
Trying to find a pattern to work around it, I'm observing changes in ApplicationMusicPlayer's state and I see that when the queue ends, queue.currentEntry matches the last entry in the queue and playbackTime is nearly zero, say less than 0.01.
But it gets more complicated, because when first playing the queue it also for a moment gets into paused state for the first track with playbackTime 0, and it could happen that I have a 1-track queue so that is also the last track in the queue. Which means by the pattern described above I'd wrongfully assume the queue has ended.
Looking for a solution to that, I found that this initial paused state is a transition from a stopped state, so if I only apply the logic above when the transition is from playing to paused, I should be good.
I'm not sure yet this is going to work OK in different platforms, right now I'm testing on Mac OS 14.5.
But we shouldn't have to deal with this. We simply need to be notified somehow that the queue has ended.
Topic:
Media Technologies
SubTopic:
General
Tags: