Bug 244595

Summary: Using "append and play" on a sorted playlist plays the wrong track
Product: [Applications] amarok Reporter: Jan Gerrit Marker <jangerrit>
Component: PlaylistAssignee: Amarok Developers <amarok-bugs-dist>
Status: RESOLVED FIXED    
Severity: normal CC: alex.merry, nhn, teo
Priority: NOR    
Version: 2.4-GIT   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In: 2.6

Description Jan Gerrit Marker 2010-07-14 12:08:17 UTC
Version:           2.3-GIT (using KDE 4.4.4) 
OS:                Linux

I execute this command:
qdbus org.kde.amarok /TrackList AddTrack ~/music/track.ogg true
The expected behavior is, that the track ~/music/track.ogg is added to the playlist and played (because of the true, which says, that the track should be played immediately: http://xmms2.org/wiki/MPRIS#AddTrack). The track is added correctly and the last track is played. But in a sorted list it's very rare that the last track is the new track.

Reproducible: Always




This issue was reported against the Audioplayercontrol runner as bug 226119 (the other bugs are runner related, but this one isn't).
Comment 1 Myriam Schweingruber 2011-09-26 15:34:29 UTC
Is this still valid with Amarok 2.4.3 or current git?
Comment 2 Jan Gerrit Marker 2011-10-21 16:29:44 UTC
It is valid with Amarok-2.4-GIT (downloaded and compiled today).

The problem occurs using sorted lists and random play (it does not matter wether random album or random track is selected). Using sorted lists results in the last track being played and using the random option results in the current track being restarted.

I reopened the bug therefore.
Comment 3 Myriam Schweingruber 2011-10-21 18:01:10 UTC
Thank you for the feedback.
Comment 4 Myriam Schweingruber 2011-10-21 18:01:35 UTC
Setting status correctly, it was not closed.
Comment 5 Jan Gerrit Marker 2011-10-21 21:07:46 UTC
Sorry, obviously I misinterpreted the bug's state.
Comment 6 Alex Merry 2012-06-11 13:00:31 UTC
This is actually an issue with the playlist implementation.  The same bug can be seen if Amarok is stopped, the playlist is sorted, and a track that will be sorted to somewhere in the middle of the list is dragged to the "Add to playlist" zone of the context view.
Comment 7 Alex Merry 2012-06-11 14:05:31 UTC
Git commit 0e07efe5908f927ba20cfbcc46298985c372c819 by Alex Merry.
Committed on 11/06/2012 at 15:57.
Pushed by alexmerry into branch 'master'.

Play the correct track when inserting tracks into a sorted playlist

When Playlist::Controller::insertOptioned() is told to play the track
that has been inserted, it previously failed to account for the
relocation of the tracks when inserted into a sorted list.  The last
track in the list would end up being played, rather than the first
inserted track.
FIXED-IN: 2.6

M  +7    -3    src/playlist/PlaylistController.cpp
M  +1    -0    src/playlist/PlaylistModel.h
M  +7    -0    src/playlist/proxymodels/AbstractModel.h
M  +6    -0    src/playlist/proxymodels/ProxyBase.cpp
M  +1    -0    src/playlist/proxymodels/ProxyBase.h

http://commits.kde.org/amarok/0e07efe5908f927ba20cfbcc46298985c372c819
Comment 8 Alex Merry 2012-06-11 14:09:18 UTC
Note that it will always play the first track from the inserted list, rather than the inserted track that is highest up the playlist, if multiple tracks are inserted at once.  This is probably not the right behaviour, but it is certainly better than before.