add CLI play-playlist option, to play given playlist name. (#608)
* add CLI play-playlist option, to play given playlist name. * Apply MR change requests
This commit is contained in:
committed by
GitHub
parent
5b5f728f49
commit
3a9a1f0a94
@@ -398,6 +398,36 @@ void Player::NextItem(const Engine::TrackChangeFlags change, const Playlist::Aut
|
||||
|
||||
}
|
||||
|
||||
void Player::PlayPlaylist(const QString &playlistName) {
|
||||
PlayPlaylistInternal(Engine::Manual, Playlist::AutoScroll_Always, playlistName);
|
||||
}
|
||||
|
||||
void Player::PlayPlaylistInternal(Engine::TrackChangeFlags change, const Playlist::AutoScroll autoscroll, const QString &playlistName) {
|
||||
Playlist *playlist = nullptr;
|
||||
for (Playlist *p : app_->playlist_manager()->GetAllPlaylists()) {
|
||||
if (playlistName == app_->playlist_manager()->GetPlaylistName(p->id())) {
|
||||
playlist = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (playlist == nullptr) {
|
||||
qLog(Warning) << "Playlist '" << playlistName << "' not found.";
|
||||
return;
|
||||
}
|
||||
|
||||
app_->playlist_manager()->SetActivePlaylist(playlist->id());
|
||||
app_->playlist_manager()->SetCurrentPlaylist(playlist->id());
|
||||
if (playlist->rowCount() == 0) return;
|
||||
|
||||
int i = app_->playlist_manager()->active()->current_row();
|
||||
if (i == -1) i = app_->playlist_manager()->active()->last_played_row();
|
||||
if (i == -1) i = 0;
|
||||
|
||||
PlayAt(i, change, autoscroll, true);
|
||||
}
|
||||
|
||||
|
||||
bool Player::HandleStopAfter(const Playlist::AutoScroll autoscroll) {
|
||||
|
||||
if (app_->playlist_manager()->active()->stop_after_current()) {
|
||||
|
||||
Reference in New Issue
Block a user