diff --git a/doc/ncmpcpprc b/doc/ncmpcpprc index 3709664c..87c78235 100644 --- a/doc/ncmpcpprc +++ b/doc/ncmpcpprc @@ -116,6 +116,8 @@ # #fancy_scrolling = "yes" # +#follow_now_playing_lyrics = "no" +# #enable_window_title = "yes" # ##### colors definitions ##### diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 3c7e0db1..ed8d970f 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -116,6 +116,7 @@ bool block_item_list_update = 0; bool messages_allowed = 0; bool redraw_screen = 0; bool redraw_header = 1; +bool reload_lyrics = 0; extern bool header_update_status; extern bool search_case_sensitive; @@ -325,7 +326,6 @@ int main(int argc, char *argv[]) messages_allowed = 1; // header stuff - const int max_allowed_title_length = wHeader->GetWidth()-volume_state.length(); if (current_screen == csBrowser && input == ERR && browsed_dir.length() > max_allowed_title_length) redraw_header = 1; @@ -412,11 +412,9 @@ int main(int argc, char *argv[]) wHeader->SetColor(Config.header_color); redraw_header = 0; } - // header stuff end // media library stuff - if (current_screen == csLibrary) { if (mLibArtists->Empty()) @@ -515,11 +513,9 @@ int main(int argc, char *argv[]) mLibSongs->Refresh(); } } - // media library end - + else // playlist editor stuff - if (current_screen == csPlaylistEditor) { if (mPlaylistList->Empty()) @@ -532,7 +528,7 @@ int main(int argc, char *argv[]) mPlaylistList->Window::Clear(); mPlaylistList->Refresh(); } - + if (mPlaylistEditor->Empty()) { mPlaylistEditor->Reset(); @@ -571,11 +567,10 @@ int main(int argc, char *argv[]) if (mPlaylistEditor->Empty()) mPlaylistEditor->WriteXY(0, 0, "Playlist is empty."); } - // playlist editor end - - // album editor stuff + else # ifdef HAVE_TAGLIB_H + // album editor stuff if (current_screen == csTagEditor) { if (mEditorLeftCol->Empty()) @@ -662,8 +657,19 @@ int main(int argc, char *argv[]) else if (mEditorTagTypes->GetChoice() >= 10) mEditorTags->Window::Clear(); } -# endif // HAVE_TAGLIB_H // album editor end + else +# endif // HAVE_TAGLIB_H + // lyrics stuff + if (current_screen == csLyrics && reload_lyrics) + { + const Song &s = mPlaylist->at(now_playing); + if (s.GetArtist() != UNKNOWN_ARTIST && s.GetTitle() != UNKNOWN_TITLE) + goto LOAD_LYRICS; + else + reload_lyrics = 0; + } + // lyrics end if (Config.columns_in_playlist && wCurrent == mPlaylist) wCurrent->Display(redraw_screen); @@ -1586,6 +1592,11 @@ int main(int argc, char *argv[]) redraw_screen = 1; } # endif // HAVE_TAGLIB_H + else if (current_screen == csLyrics) + { + Config.now_playing_lyrics = !Config.now_playing_lyrics; + ShowMessage("Reload lyrics if song changes: " + string(Config.now_playing_lyrics ? "On" : "Off")); + } } } else if (Keypressed(input, Key.VolumeUp)) @@ -2968,8 +2979,21 @@ int main(int argc, char *argv[]) || (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty()) || (wCurrent == mEditorTags && !mEditorTags->Empty())) { + LOAD_LYRICS: + Song *s; - int id = wCurrent->GetChoice(); + int id; + + if (reload_lyrics) + { + current_screen = csPlaylist; + wCurrent = mPlaylist; + reload_lyrics = 0; + id = now_playing; + } + else + id = wCurrent->GetChoice(); + switch (current_screen) { case csPlaylist: diff --git a/src/settings.cpp b/src/settings.cpp index e27056c1..ce08a6c0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -186,6 +186,7 @@ void DefaultConfiguration(ncmpcpp_config &conf) conf.space_selects = false; conf.albums_in_tag_editor = false; conf.incremental_seeking = true; + conf.now_playing_lyrics = false; conf.set_window_title = true; conf.mpd_connection_timeout = 15; conf.crossfade_time = 5; @@ -569,6 +570,10 @@ void ReadConfiguration(ncmpcpp_config &conf) { conf.incremental_seeking = v == "yes"; } + else if (it->find("follow_now_playing_lyrics") != string::npos) + { + conf.now_playing_lyrics = v == "yes"; + } else if (it->find("enable_window_title") != string::npos) { conf.set_window_title = v == "yes"; diff --git a/src/settings.h b/src/settings.h index d9f709e6..9529ddcc 100644 --- a/src/settings.h +++ b/src/settings.h @@ -135,6 +135,7 @@ struct ncmpcpp_config bool space_selects; bool albums_in_tag_editor; bool incremental_seeking; + bool now_playing_lyrics; int mpd_connection_timeout; int crossfade_time; diff --git a/src/status_checker.cpp b/src/status_checker.cpp index 0e5eeed0..3c48a5ba 100644 --- a/src/status_checker.cpp +++ b/src/status_checker.cpp @@ -61,6 +61,7 @@ extern string mpd_crossfade; extern string mpd_db_updating; extern NcmpcppScreen current_screen; +extern NcmpcppScreen prev_screen; extern bool dont_change_now_playing; extern bool allow_statusbar_unlock; @@ -71,6 +72,7 @@ extern bool block_item_list_update; extern bool redraw_screen; extern bool redraw_header; +extern bool reload_lyrics; bool header_update_status = 0; bool repeat_one_allowed = 0; @@ -308,6 +310,9 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da if (!Mpd->GetElapsedTime()) mvwhline(wFooter->RawWin(), 0, 0, 0, wFooter->GetWidth()); + + if (Config.now_playing_lyrics && current_screen == csLyrics && prev_screen == csPlaylist) + reload_lyrics = 1; } playing_song_scroll_begin = 0;