Question about Playlist::activate().
Added by Sho Tanimoto over 4 years ago
Hi, I have a question about Playlist::activate().
The audqt::TreeView in the plugin window shows the directory listing and The playlist "PLAYLIST" is created from the user's selection.If PLAYLIST already exists and it is playing at that time, the old one will be renamed to PLAYING.This is because I don't want to stop playback. Then I want to display the newly created PLAYLIST with activate(), but PLAYING is still active.
When renaming to PLAYING, if the PLAYING already exists, the old one must be deleted. If I comment out this process (although PLAYING will accumulate) it will work the way I want it to work.
Is there any specification I am missing? Or is there a better way to do it? Thank you.
Here's my TreeView::selectionChanged().
void LibraryTreeView::selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
{
auto playlist = find_playlist(PLAYLIST_TITLE);
auto playing = find_playlist(PLAYING_TITLE);
auto current = Playlist::playing_playlist();
bool is_new_playlist_needed = (playlist == Playlist());
if(playlist == current){
if(playing != Playlist()){
playing.remove_playlist(); /* this line ? */
}
current.set_title(PLAYING_TITLE);
is_new_playlist_needed = true;
}
if(is_new_playlist_needed) {
playlist = Playlist::blank_playlist();
playlist.set_title(PLAYLIST_TITLE);
}
Index<PlaylistAddItem> add;
for(auto index : selectedIndexes()) {
if(!index.isValid())
continue;
auto filename = directory_structure_model->filePath(index);
if(filename.isEmpty())
continue;
auto ptr = filename.toUtf8().data();
auto uri = filename_to_uri(ptr);
add.append(String(uri));
}
if(add.len()) {
playlist.remove_all_entries();
playlist.insert_items(-1, std::move(add), false);
}
playlist.activate();
update();
}
Replies (4)
RE: Question about Playlist::activate(). - Added by John Lindgren over 4 years ago
I don't understand exactly what issue you're running into, but documentation for playlist functions can be found in /usr/include/libaudcore/playlist.h.
RE: Question about Playlist::activate(). - Added by Sho Tanimoto over 4 years ago
Sorry, the situation was a bit too complicated. This problem can be simplified like this.
func(){
p1.remove_playlist();
auto p3 = Playlist::new_playlist();
p3.set_title("p3");
p3.activate();
}
Playlist p1,p2 exists beforehand. func() deletes p1, and p3 will be newly created. After this, I expect p3 to be active, but it is actually p2 is active.
After p3 became active, I found qtui\playlist_tabs.cc:159 currentChangedTrigger() makes p2 active.
The PlaylistTabs widget seems to be related to this issue. But I have no idea how to deal with this. Does anyone have any hints ?
RE: Question about Playlist::activate(). - Added by John Lindgren over 4 years ago
That seems to be a bug in qtui. Should be fixed now.
https://github.com/audacious-media-player/audacious-plugins/commit/98cce52a71499ef865e498abb49f26abf7be6fa6
RE: Question about Playlist::activate(). - Added by Sho Tanimoto over 4 years ago
It works now!
Thank you.