diff --git a/src/ui/LmsApplication.cpp b/src/ui/LmsApplication.cpp index b231940a..78e53c7f 100644 --- a/src/ui/LmsApplication.cpp +++ b/src/ui/LmsApplication.cpp @@ -447,9 +447,17 @@ LmsApplication::createHome() }); // Events from the PlayQueue - playqueue->playTrack.connect(playhistory, &PlayHistory::addTrack); - playqueue->playTrack.connect(explore, &Explore::handleTrackPlayed); - playqueue->playTrack.connect(player, &MediaPlayer::playTrack); + playqueue->loadTrack.connect([=](Database::IdType trackId, bool play) + { + playhistory->addTrack(trackId); + }); + + playqueue->loadTrack.connect([=](Database::IdType trackId, bool play) + { + explore->handleTrackPlayed(trackId); + }); + + playqueue->loadTrack.connect(player, &MediaPlayer::loadTrack); playqueue->playbackStop.connect(player, &MediaPlayer::stop); diff --git a/src/ui/MediaPlayer.cpp b/src/ui/MediaPlayer.cpp index 521888f2..63c9e13b 100644 --- a/src/ui/MediaPlayer.cpp +++ b/src/ui/MediaPlayer.cpp @@ -51,7 +51,7 @@ MediaPlayer::MediaPlayer() } void -MediaPlayer::playTrack(Database::IdType trackId) +MediaPlayer::loadTrack(Database::IdType trackId, bool play) { LMS_LOG(UI, DEBUG) << "Playing track ID = " << trackId; @@ -72,7 +72,7 @@ MediaPlayer::playTrack(Database::IdType trackId) << " duration: " << std::chrono::duration_cast(track->getDuration()).count() << "," << " imgResource: \"" << imgResource << "\"," << "};"; - oss << "LMS.mediaplayer.loadTrack(params, true)"; // true to autoplay + oss << "LMS.mediaplayer.loadTrack(params, " << (play ? "true" : "false") << ")"; // true to autoplay LMS_LOG(UI, DEBUG) << "Runing js = '" << oss.str() << "'"; diff --git a/src/ui/MediaPlayer.hpp b/src/ui/MediaPlayer.hpp index d5d83315..02125d15 100644 --- a/src/ui/MediaPlayer.hpp +++ b/src/ui/MediaPlayer.hpp @@ -34,7 +34,7 @@ class MediaPlayer : public Wt::WTemplate MediaPlayer(); void stop(); - void playTrack(Database::IdType trackId); + void loadTrack(Database::IdType trackId, bool play); // Signals Wt::JSignal<> playbackEnded; diff --git a/src/ui/PlayQueueView.cpp b/src/ui/PlayQueueView.cpp index 4c7bf974..a37b318d 100644 --- a/src/ui/PlayQueueView.cpp +++ b/src/ui/PlayQueueView.cpp @@ -92,7 +92,7 @@ PlayQueue::PlayQueue() { LmsApp->post([=] { - play(LmsApp->getUser()->getCurPlayingTrackPos()); + load(LmsApp->getUser()->getCurPlayingTrackPos(), false); }); } } @@ -139,7 +139,7 @@ PlayQueue::stop() } void -PlayQueue::play(std::size_t pos) +PlayQueue::load(std::size_t pos, bool play) { updateCurrentTrack(false); @@ -171,7 +171,7 @@ PlayQueue::play(std::size_t pos) LmsApp->getUser().modify()->setCurPlayingTrackPos(pos); } - playTrack.emit(trackId); + loadTrack.emit(trackId, play); } void @@ -183,7 +183,7 @@ PlayQueue::playPrevious() if (*_trackPos == 0) stop(); else - play(*_trackPos - 1); + load(*_trackPos - 1, true); } void @@ -191,11 +191,11 @@ PlayQueue::playNext() { if (!_trackPos) { - play(0); + load(0, true); return; } - play(*_trackPos + 1); + load(*_trackPos + 1, true); } void @@ -257,7 +257,7 @@ PlayQueue::playTracks(const std::vector& tracks) clearTracks(); enqueueTracks(tracks); - play(0); + load(0, true); LmsApp->notifyMsg(MsgType::Info, Wt::WString::tr("Lms.PlayQueue.nb-tracks-playing").arg(tracks.size()), std::chrono::milliseconds(2000)); } @@ -298,7 +298,7 @@ PlayQueue::addSome() { auto pos = _entriesContainer->indexOf(entry); if (pos >= 0) - play(pos); + load(pos, true); })); Wt::WText* delBtn = entry->bindNew("del-btn", Wt::WString::tr("Lms.PlayQueue.delete"), Wt::TextFormat::XHTML); diff --git a/src/ui/PlayQueueView.hpp b/src/ui/PlayQueueView.hpp index 7d0dacc8..dd08ca43 100644 --- a/src/ui/PlayQueueView.hpp +++ b/src/ui/PlayQueueView.hpp @@ -47,8 +47,8 @@ class PlayQueue : public Wt::WTemplate // play the previous track in the queue void playPrevious(); - // Signal emitted when a track is to be played - Wt::Signal playTrack; + // Signal emitted when a track is to be load(and optionally played) + Wt::Signal loadTrack; // Signal emitted when play has to be stopped Wt::Signal<> playbackStop; @@ -64,7 +64,7 @@ class PlayQueue : public Wt::WTemplate void updateInfo(); void updateCurrentTrack(bool selected); - void play(std::size_t pos); + void load(std::size_t pos, bool play); void stop(); boost::optional _tracklistId;