Prevent autoplay when connecting to LMS
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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<std::chrono::seconds>(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() << "'";
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<Database::Track::pointer>& 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<Wt::WText>("del-btn", Wt::WString::tr("Lms.PlayQueue.delete"), Wt::TextFormat::XHTML);
|
||||
|
||||
@@ -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<Database::IdType> playTrack;
|
||||
// Signal emitted when a track is to be load(and optionally played)
|
||||
Wt::Signal<Database::IdType /*trackId*/, bool /*play*/> 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<Database::IdType> _tracklistId;
|
||||
|
||||
Reference in New Issue
Block a user