diff --git a/doc/config b/doc/config index 458b3716..39544c3f 100644 --- a/doc/config +++ b/doc/config @@ -201,6 +201,8 @@ # #clock_display_seconds = "no" # +#display_bitrate = "no" +# #regular_expressions = "basic" (basic/extended) # ## diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1 index ac9a7111..218370e6 100644 --- a/doc/ncmpcpp.1 +++ b/doc/ncmpcpp.1 @@ -192,6 +192,9 @@ If enabled, user will be asked if he really wants to clear the main playlist aft .B clock_display_seconds = yes/no If enabled, clock will display time in format hh:mm:ss, otherwise hh:mm. .TP +.B display_bitrate = yes/no +If enabled, bitrate of currently playing song will be displayed in statusbar. +.TP .B ignore_leading_the = yes/no If enabled, word "the" at the beginning of tags/filenames will be ignored while sorting items. .TP diff --git a/src/mpdpp.h b/src/mpdpp.h index b13412dc..2bbca866 100644 --- a/src/mpdpp.h +++ b/src/mpdpp.h @@ -129,6 +129,7 @@ namespace MPD long long GetPlaylistID() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->playlist : -1; } long long GetOldPlaylistID() const { return isConnected && itsOldStatus ? itsOldStatus->playlist : -1; } int GetElapsedTime() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->elapsedTime : -1; } + unsigned GetBitrate() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->bitRate : 0; } size_t GetMaxPlaylistLength() const { return itsMaxPlaylistLength; } size_t GetPlaylistLength() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->playlistLength : 0; } diff --git a/src/settings.cpp b/src/settings.cpp index eaa99c3e..73ffab28 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -289,6 +289,7 @@ void DefaultConfiguration(ncmpcpp_config &conf) conf.search_in_db = true; conf.display_screens_numbers_on_start = true; conf.clock_display_seconds = false; + conf.display_bitrate = false; conf.ignore_leading_the = false; conf.block_search_constraints_change = true; conf.use_console_editor = false; @@ -723,6 +724,10 @@ void ReadConfiguration(ncmpcpp_config &conf) { conf.clock_display_seconds = v == "yes"; } + else if (cl.find("display_bitrate") != std::string::npos) + { + conf.display_bitrate = v == "yes"; + } else if (cl.find("ignore_leading_the") != std::string::npos) { conf.ignore_leading_the = v == "yes"; diff --git a/src/settings.h b/src/settings.h index f4813d34..c16cc563 100644 --- a/src/settings.h +++ b/src/settings.h @@ -184,6 +184,7 @@ struct ncmpcpp_config bool search_in_db; bool display_screens_numbers_on_start; bool clock_display_seconds; + bool display_bitrate; bool ignore_leading_the; bool block_search_constraints_change; bool use_console_editor; diff --git a/src/status.cpp b/src/status.cpp index d7788547..fc63fddf 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -421,6 +421,13 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *) tracklength += "/"; tracklength += np.GetLength(); } + // bitrate here doesn't look good, but it can be moved somewhere else later + if (Config.display_bitrate && Mpd.GetBitrate()) + { + tracklength += " "; + tracklength += IntoStr(Mpd.GetBitrate()); + tracklength += " kbps"; + } basic_buffer first, second; String2Buffer(TO_WSTRING(utf_to_locale_cpy(np.toString(Config.new_header_first_line))), first); @@ -449,9 +456,15 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *) } else if (!block_statusbar_update && Config.statusbar_visibility) { + if (Config.display_bitrate && Mpd.GetBitrate()) + { + tracklength += " ["; + tracklength += IntoStr(Mpd.GetBitrate()); + tracklength += " kbps]"; + } + tracklength += " ["; if (np.GetTotalLength()) { - tracklength = " ["; tracklength += Song::ShowTime(elapsed); tracklength += "/"; tracklength += np.GetLength(); @@ -459,7 +472,6 @@ void NcmpcppStatusChanged(Connection *, StatusChanges changed, void *) } else { - tracklength = " ["; tracklength += Song::ShowTime(elapsed); tracklength += "]"; }