mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-19 04:50:16 +01:00
Don't reshuffle the playlist every time the user presses next
This commit is contained in:
parent
7d1c5a3a1b
commit
70565565c7
@ -333,7 +333,7 @@ MainWindow::MainWindow(QNetworkAccessManager* network, Engine::Type engine, QWid
|
||||
connect(radio_model_, SIGNAL(TaskStarted(MultiLoadingIndicator::TaskType)), multi_loading_indicator_, SLOT(TaskStarted(MultiLoadingIndicator::TaskType)));
|
||||
connect(radio_model_, SIGNAL(TaskFinished(MultiLoadingIndicator::TaskType)), multi_loading_indicator_, SLOT(TaskFinished(MultiLoadingIndicator::TaskType)));
|
||||
connect(radio_model_, SIGNAL(StreamError(QString)), SLOT(ReportError(QString)));
|
||||
connect(radio_model_, SIGNAL(StreamFinished()), player_, SLOT(NextItem()));
|
||||
connect(radio_model_, SIGNAL(StreamFinished()), player_, SLOT(RadioStreamFinished()));
|
||||
connect(radio_model_, SIGNAL(StreamReady(QUrl,QUrl)), player_, SLOT(StreamReady(QUrl,QUrl)));
|
||||
connect(radio_model_, SIGNAL(StreamMetadataFound(QUrl,Song)), playlist_, SLOT(SetStreamMetadata(QUrl,Song)));
|
||||
connect(radio_model_, SIGNAL(AddItemToPlaylist(RadioItem*)), SLOT(InsertRadioItem(RadioItem*)));
|
||||
@ -474,7 +474,7 @@ void MainWindow::QueueFiles(const QList<QUrl>& urls) {
|
||||
QModelIndex playlist_index = playlist_->InsertPaths(urls);
|
||||
|
||||
if (playlist_index.isValid() && player_->GetState() != Engine::Playing)
|
||||
player_->PlayAt(playlist_index.row(), Engine::First);
|
||||
player_->PlayAt(playlist_index.row(), Engine::First, true);
|
||||
}
|
||||
|
||||
void MainWindow::ReportError(const QString& message) {
|
||||
@ -563,7 +563,7 @@ void MainWindow::PlayIndex(const QModelIndex& index) {
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
player_->PlayAt(index.row(), Engine::Manual);
|
||||
player_->PlayAt(index.row(), Engine::Manual, true);
|
||||
}
|
||||
|
||||
void MainWindow::AddLibraryItemToPlaylist(const QModelIndex& index) {
|
||||
@ -575,7 +575,7 @@ void MainWindow::AddLibraryItemToPlaylist(const QModelIndex& index) {
|
||||
playlist_->InsertLibraryItems(library_->GetChildSongs(idx));
|
||||
|
||||
if (first_song.isValid() && player_->GetState() != Engine::Playing)
|
||||
player_->PlayAt(first_song.row(), Engine::First);
|
||||
player_->PlayAt(first_song.row(), Engine::First, true);
|
||||
}
|
||||
|
||||
void MainWindow::VolumeWheelEvent(int delta) {
|
||||
@ -692,7 +692,7 @@ void MainWindow::InsertRadioItem(RadioItem* item) {
|
||||
QList<RadioItem*>() << item);
|
||||
|
||||
if (first_song.isValid() && player_->GetState() != Engine::Playing)
|
||||
player_->PlayAt(first_song.row(), Engine::Manual);
|
||||
player_->PlayAt(first_song.row(), Engine::First, true);
|
||||
}
|
||||
|
||||
void MainWindow::PlaylistRightClick(const QPoint& global_pos, const QModelIndex& index) {
|
||||
@ -763,7 +763,7 @@ void MainWindow::PlaylistPlay() {
|
||||
if (playlist_->current_index() == playlist_menu_index_.row()) {
|
||||
player_->PlayPause();
|
||||
} else {
|
||||
player_->PlayAt(playlist_menu_index_.row(), Engine::Manual);
|
||||
player_->PlayAt(playlist_menu_index_.row(), Engine::Manual, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -980,7 +980,7 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
|
||||
player_->Previous();
|
||||
break;
|
||||
case CommandlineOptions::Player_Next:
|
||||
player_->Next(Engine::Manual);
|
||||
player_->Next();
|
||||
break;
|
||||
|
||||
case CommandlineOptions::Player_None:
|
||||
@ -1009,7 +1009,7 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
|
||||
player_->Seek(player_->PositionGet() / 1000 + options.seek_by());
|
||||
|
||||
if (options.play_track_at() != -1)
|
||||
player_->PlayAt(options.play_track_at(), Engine::Manual);
|
||||
player_->PlayAt(options.play_track_at(), Engine::Manual, true);
|
||||
|
||||
if (options.show_osd())
|
||||
player_->ShowOSD();
|
||||
|
@ -141,18 +141,22 @@ void Player::ReloadSettings() {
|
||||
engine_->ReloadSettings();
|
||||
}
|
||||
|
||||
void Player::NextAuto() {
|
||||
Next(Engine::Auto);
|
||||
void Player::RadioStreamFinished() {
|
||||
NextInternal(Engine::Auto);
|
||||
}
|
||||
|
||||
void Player::Next(Engine::TrackChangeType change) {
|
||||
void Player::Next() {
|
||||
NextInternal(Engine::Manual);
|
||||
}
|
||||
|
||||
void Player::NextInternal(Engine::TrackChangeType change) {
|
||||
if (playlist_->current_item_options() & PlaylistItem::ContainsMultipleTracks) {
|
||||
stream_change_type_ = change;
|
||||
playlist_->current_item()->LoadNext();
|
||||
return;
|
||||
}
|
||||
|
||||
NextItem(change);
|
||||
NextItem(Engine::Manual);
|
||||
}
|
||||
|
||||
void Player::NextItem(Engine::TrackChangeType change) {
|
||||
@ -164,7 +168,7 @@ void Player::NextItem(Engine::TrackChangeType change) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayAt(i, change);
|
||||
PlayAt(i, change, false);
|
||||
}
|
||||
|
||||
void Player::TrackEnded() {
|
||||
@ -173,7 +177,7 @@ void Player::TrackEnded() {
|
||||
return;
|
||||
}
|
||||
|
||||
Next(Engine::Auto);
|
||||
NextInternal(Engine::Auto);
|
||||
}
|
||||
|
||||
void Player::PlayPause() {
|
||||
@ -201,7 +205,7 @@ void Player::PlayPause() {
|
||||
if (i == -1) i = playlist_->last_played_index();
|
||||
if (i == -1) i = 0;
|
||||
|
||||
PlayAt(i, Engine::First);
|
||||
PlayAt(i, Engine::First, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -220,7 +224,7 @@ void Player::Previous() {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayAt(i, Engine::Manual);
|
||||
PlayAt(i, Engine::Manual, false);
|
||||
}
|
||||
|
||||
void Player::EngineStateChanged(Engine::State state) {
|
||||
@ -253,9 +257,9 @@ Engine::State Player::GetState() const {
|
||||
return engine_->state();
|
||||
}
|
||||
|
||||
void Player::PlayAt(int index, Engine::TrackChangeType change) {
|
||||
if (change != Engine::Auto)
|
||||
playlist_->set_current_index(-1); // to reshuffle
|
||||
void Player::PlayAt(int index, Engine::TrackChangeType change, bool reshuffle) {
|
||||
if (reshuffle)
|
||||
playlist_->set_current_index(-1);
|
||||
playlist_->set_current_index(index);
|
||||
|
||||
shared_ptr<PlaylistItem> item = playlist_->item_at(index);
|
||||
@ -488,7 +492,7 @@ int Player::AddTrack(const QString& track, bool play_now) {
|
||||
|
||||
if (index.isValid()) {
|
||||
if (play_now) {
|
||||
Next(Engine::First);
|
||||
PlayAt(index.row(), Engine::First, true);
|
||||
}
|
||||
return 0; // Success.
|
||||
}
|
||||
@ -518,7 +522,7 @@ void Player::SetRandom(bool enable) {
|
||||
}
|
||||
|
||||
void Player::PlayTrack(int index) {
|
||||
PlayAt(index, Engine::Manual);
|
||||
PlayAt(index, Engine::Manual, true);
|
||||
}
|
||||
|
||||
void Player::PlaylistChanged() {
|
||||
@ -529,7 +533,7 @@ void Player::TrackAboutToEnd() {
|
||||
if (engine_->is_autocrossfade_enabled()) {
|
||||
// Crossfade is on, so just start playing the next track. The current one
|
||||
// will fade out, and the new one will fade in
|
||||
NextAuto();
|
||||
NextInternal(Engine::Auto);
|
||||
} else {
|
||||
// Crossfade is off, so start preloading the next track so we don't get a
|
||||
// gap between songs.
|
||||
|
24
src/player.h
24
src/player.h
@ -79,14 +79,23 @@ class Player : public QObject {
|
||||
public slots:
|
||||
void ReloadSettings();
|
||||
|
||||
void PlayAt(int index, Engine::TrackChangeType change);
|
||||
// Manual track change to the specified track
|
||||
void PlayAt(int i, Engine::TrackChangeType change, bool reshuffle);
|
||||
|
||||
// If there's currently a song playing, pause it, otherwise play the track
|
||||
// that was playing last, or the first one on the playlist
|
||||
void PlayPause();
|
||||
void NextItem(Engine::TrackChangeType change = Engine::Auto);
|
||||
|
||||
// Skips this track. Might load more of the current radio station.
|
||||
void Next();
|
||||
|
||||
// Jumps to the next actual item on the playlist, with an automatic change
|
||||
void RadioStreamFinished();
|
||||
|
||||
void Previous();
|
||||
void SetVolume(int value);
|
||||
void Seek(int seconds);
|
||||
|
||||
void TrackEnded();
|
||||
void StreamReady(const QUrl& original_url, const QUrl& media_url);
|
||||
void CurrentMetadataChanged(const Song& metadata);
|
||||
|
||||
@ -100,7 +109,6 @@ class Player : public QObject {
|
||||
void Pause();
|
||||
void Stop();
|
||||
void Play();
|
||||
void Next(Engine::TrackChangeType change = Engine::Manual);
|
||||
void Prev();
|
||||
int PositionGet() const;
|
||||
void PositionSet(int);
|
||||
@ -144,8 +152,14 @@ class Player : public QObject {
|
||||
private slots:
|
||||
void EngineStateChanged(Engine::State);
|
||||
void EngineMetadataReceived(const Engine::SimpleMetaBundle& bundle);
|
||||
void NextAuto();
|
||||
void TrackAboutToEnd();
|
||||
void TrackEnded();
|
||||
|
||||
// Play the next item on the playlist - disregarding radio stations like
|
||||
// last.fm that might have more tracks.
|
||||
void NextItem(Engine::TrackChangeType change);
|
||||
|
||||
void NextInternal(Engine::TrackChangeType);
|
||||
|
||||
private:
|
||||
QVariantMap GetMetadata(const PlaylistItem& item) const;
|
||||
|
Loading…
Reference in New Issue
Block a user