Bug 488690 - "Add to playlist" interrupts playback and plays another song at random (when shuffle is active)
Summary: "Add to playlist" interrupts playback and plays another song at random (when ...
Status: RESOLVED FIXED
Alias: None
Product: Elisa
Classification: Applications
Component: general (show other bugs)
Version: 24.05.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Matthieu Gallien
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-18 21:09 UTC by hut
Modified: 2024-06-22 05:31 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 24.08.0
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description hut 2024-06-18 21:09:38 UTC
SUMMARY

When Shuffle is active, adding tracks to the playlist may interrupt currently played song and play a random other one

STEPS TO REPRODUCE

1. Enable shuffle
2. Clear playlist
3. Add 1 track to playlist
4. Play the track
5. Add an album with many (e.g. 10+) tracks

OBSERVED RESULT

The current track stops playing, another random track starts playing.

EXPECTED RESULT

The current track continues playing

ADDITIONAL INFORMATION

This is because the new tracks are inserted into a random place in the playlist and if they, by chance, hit the same index as the currently playing track, the old track is stopped and the new track at that index is started.

There's actually a low chance that the expected result happens (when by chance the insertion index is always different than the index of the current song).
Comment 1 Bug Janitor Service 2024-06-19 20:35:17 UTC
A possibly relevant merge request was started @ https://invent.kde.org/multimedia/elisa/-/merge_requests/593
Comment 2 Jack Hill 2024-06-21 13:59:59 UTC
Git commit fe01ad59ca132e8b447bb6b1edb4536eb69ec24a by Jack Hill.
Committed on 21/06/2024 at 13:55.
Pushed by jackh into branch 'master'.

MediaPlayListProxyModel: only enqueue after the current track when shuffled

and only after the current album when in album shuffle mode.

Typically if a user wants to enqueue a track, they also want to hear the
track at some point.

Also fixes an issue where the enqueued track could sometimes enqueue at
the index of the currently playing track, causing the current track to
change.

M  +30   -5    autotests/mediaplaylistproxymodeltest.cpp
M  +14   -2    src/mediaplaylistproxymodel.cpp

https://invent.kde.org/multimedia/elisa/-/commit/fe01ad59ca132e8b447bb6b1edb4536eb69ec24a