support for following lyrics of now playing song

This commit is contained in:
unK
2008-09-20 20:06:14 +02:00
parent f0a810cdc0
commit aa80c13c2e
5 changed files with 49 additions and 12 deletions

View File

@@ -116,6 +116,8 @@
# #
#fancy_scrolling = "yes" #fancy_scrolling = "yes"
# #
#follow_now_playing_lyrics = "no"
#
#enable_window_title = "yes" #enable_window_title = "yes"
# #
##### colors definitions ##### ##### colors definitions #####

View File

@@ -116,6 +116,7 @@ bool block_item_list_update = 0;
bool messages_allowed = 0; bool messages_allowed = 0;
bool redraw_screen = 0; bool redraw_screen = 0;
bool redraw_header = 1; bool redraw_header = 1;
bool reload_lyrics = 0;
extern bool header_update_status; extern bool header_update_status;
extern bool search_case_sensitive; extern bool search_case_sensitive;
@@ -325,7 +326,6 @@ int main(int argc, char *argv[])
messages_allowed = 1; messages_allowed = 1;
// header stuff // header stuff
const int max_allowed_title_length = wHeader->GetWidth()-volume_state.length(); const int max_allowed_title_length = wHeader->GetWidth()-volume_state.length();
if (current_screen == csBrowser && input == ERR && browsed_dir.length() > max_allowed_title_length) if (current_screen == csBrowser && input == ERR && browsed_dir.length() > max_allowed_title_length)
redraw_header = 1; redraw_header = 1;
@@ -412,11 +412,9 @@ int main(int argc, char *argv[])
wHeader->SetColor(Config.header_color); wHeader->SetColor(Config.header_color);
redraw_header = 0; redraw_header = 0;
} }
// header stuff end // header stuff end
// media library stuff // media library stuff
if (current_screen == csLibrary) if (current_screen == csLibrary)
{ {
if (mLibArtists->Empty()) if (mLibArtists->Empty())
@@ -515,11 +513,9 @@ int main(int argc, char *argv[])
mLibSongs->Refresh(); mLibSongs->Refresh();
} }
} }
// media library end // media library end
else
// playlist editor stuff // playlist editor stuff
if (current_screen == csPlaylistEditor) if (current_screen == csPlaylistEditor)
{ {
if (mPlaylistList->Empty()) if (mPlaylistList->Empty())
@@ -532,7 +528,7 @@ int main(int argc, char *argv[])
mPlaylistList->Window::Clear(); mPlaylistList->Window::Clear();
mPlaylistList->Refresh(); mPlaylistList->Refresh();
} }
if (mPlaylistEditor->Empty()) if (mPlaylistEditor->Empty())
{ {
mPlaylistEditor->Reset(); mPlaylistEditor->Reset();
@@ -571,11 +567,10 @@ int main(int argc, char *argv[])
if (mPlaylistEditor->Empty()) if (mPlaylistEditor->Empty())
mPlaylistEditor->WriteXY(0, 0, "Playlist is empty."); mPlaylistEditor->WriteXY(0, 0, "Playlist is empty.");
} }
// playlist editor end // playlist editor end
else
// album editor stuff
# ifdef HAVE_TAGLIB_H # ifdef HAVE_TAGLIB_H
// album editor stuff
if (current_screen == csTagEditor) if (current_screen == csTagEditor)
{ {
if (mEditorLeftCol->Empty()) if (mEditorLeftCol->Empty())
@@ -662,8 +657,19 @@ int main(int argc, char *argv[])
else if (mEditorTagTypes->GetChoice() >= 10) else if (mEditorTagTypes->GetChoice() >= 10)
mEditorTags->Window::Clear(); mEditorTags->Window::Clear();
} }
# endif // HAVE_TAGLIB_H
// album editor end // 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) if (Config.columns_in_playlist && wCurrent == mPlaylist)
wCurrent->Display(redraw_screen); wCurrent->Display(redraw_screen);
@@ -1586,6 +1592,11 @@ int main(int argc, char *argv[])
redraw_screen = 1; redraw_screen = 1;
} }
# endif // HAVE_TAGLIB_H # 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)) else if (Keypressed(input, Key.VolumeUp))
@@ -2968,8 +2979,21 @@ int main(int argc, char *argv[])
|| (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty()) || (wCurrent == mPlaylistEditor && !mPlaylistEditor->Empty())
|| (wCurrent == mEditorTags && !mEditorTags->Empty())) || (wCurrent == mEditorTags && !mEditorTags->Empty()))
{ {
LOAD_LYRICS:
Song *s; 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) switch (current_screen)
{ {
case csPlaylist: case csPlaylist:

View File

@@ -186,6 +186,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
conf.space_selects = false; conf.space_selects = false;
conf.albums_in_tag_editor = false; conf.albums_in_tag_editor = false;
conf.incremental_seeking = true; conf.incremental_seeking = true;
conf.now_playing_lyrics = false;
conf.set_window_title = true; conf.set_window_title = true;
conf.mpd_connection_timeout = 15; conf.mpd_connection_timeout = 15;
conf.crossfade_time = 5; conf.crossfade_time = 5;
@@ -569,6 +570,10 @@ void ReadConfiguration(ncmpcpp_config &conf)
{ {
conf.incremental_seeking = v == "yes"; 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) else if (it->find("enable_window_title") != string::npos)
{ {
conf.set_window_title = v == "yes"; conf.set_window_title = v == "yes";

View File

@@ -135,6 +135,7 @@ struct ncmpcpp_config
bool space_selects; bool space_selects;
bool albums_in_tag_editor; bool albums_in_tag_editor;
bool incremental_seeking; bool incremental_seeking;
bool now_playing_lyrics;
int mpd_connection_timeout; int mpd_connection_timeout;
int crossfade_time; int crossfade_time;

View File

@@ -61,6 +61,7 @@ extern string mpd_crossfade;
extern string mpd_db_updating; extern string mpd_db_updating;
extern NcmpcppScreen current_screen; extern NcmpcppScreen current_screen;
extern NcmpcppScreen prev_screen;
extern bool dont_change_now_playing; extern bool dont_change_now_playing;
extern bool allow_statusbar_unlock; extern bool allow_statusbar_unlock;
@@ -71,6 +72,7 @@ extern bool block_item_list_update;
extern bool redraw_screen; extern bool redraw_screen;
extern bool redraw_header; extern bool redraw_header;
extern bool reload_lyrics;
bool header_update_status = 0; bool header_update_status = 0;
bool repeat_one_allowed = 0; bool repeat_one_allowed = 0;
@@ -308,6 +310,9 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da
if (!Mpd->GetElapsedTime()) if (!Mpd->GetElapsedTime())
mvwhline(wFooter->RawWin(), 0, 0, 0, wFooter->GetWidth()); 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; playing_song_scroll_begin = 0;