status: if current song is not yet in playlist, fetch it from the server - part 2
This commit is contained in:
@@ -78,6 +78,17 @@ unsigned m_playlist_length;
|
|||||||
unsigned m_total_time;
|
unsigned m_total_time;
|
||||||
int m_volume;
|
int m_volume;
|
||||||
|
|
||||||
|
MPD::Song getCurrentSong()
|
||||||
|
{
|
||||||
|
MPD::Song result = myPlaylist->nowPlayingSong();
|
||||||
|
// It may happen that playlist wasn't yet updated
|
||||||
|
// and current song is not there yet. In such case
|
||||||
|
// try fetching it from the server.
|
||||||
|
if (result.empty() && m_player_state != MPD::psUnknown)
|
||||||
|
result = Mpd.GetCurrentSong();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void drawTitle(const MPD::Song &np)
|
void drawTitle(const MPD::Song &np)
|
||||||
{
|
{
|
||||||
assert(!np.empty());
|
assert(!np.empty());
|
||||||
@@ -478,7 +489,7 @@ void Status::Changes::playerState()
|
|||||||
switch (m_player_state)
|
switch (m_player_state)
|
||||||
{
|
{
|
||||||
case MPD::psPlay:
|
case MPD::psPlay:
|
||||||
drawTitle(myPlaylist->nowPlayingSong());
|
drawTitle(getCurrentSong());
|
||||||
myPlaylist->reloadRemaining();
|
myPlaylist->reloadRemaining();
|
||||||
break;
|
break;
|
||||||
case MPD::psStop:
|
case MPD::psStop:
|
||||||
@@ -578,17 +589,12 @@ void Status::Changes::elapsedTime(bool update_elapsed)
|
|||||||
*wFooter << NC::XY(0, 1) << NC::TermManip::ClearToEOL;
|
*wFooter << NC::XY(0, 1) << NC::TermManip::ClearToEOL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MPD::Song np = getCurrentSong();
|
||||||
std::string ps = playerStateToString(m_player_state);
|
std::string ps = playerStateToString(m_player_state);
|
||||||
MPD::Song np = myPlaylist->nowPlayingSong();
|
|
||||||
// It may happen that playlist wasn't yet updated
|
|
||||||
// and current song is not there yet. In such case
|
|
||||||
// try fetching it from the server.
|
|
||||||
if (np.empty() && (m_player_state == MPD::psPlay || m_player_state == MPD::psPause))
|
|
||||||
np = Mpd.GetCurrentSong();
|
|
||||||
drawTitle(np);
|
|
||||||
|
|
||||||
std::string tracklength;
|
std::string tracklength;
|
||||||
|
|
||||||
|
drawTitle(np);
|
||||||
switch (Config.design)
|
switch (Config.design)
|
||||||
{
|
{
|
||||||
case Design::Classic:
|
case Design::Classic:
|
||||||
|
|||||||
Reference in New Issue
Block a user