add incremental seeking as an option (enabled by default)
This commit is contained in:
@@ -96,6 +96,8 @@
|
||||
#
|
||||
#playlist_display_mode = "normal" (classic/columns)
|
||||
#
|
||||
#incremental_seeking = "yes"
|
||||
#
|
||||
#autocenter_mode = "no"
|
||||
#
|
||||
#repeat_one_mode = "no"
|
||||
@@ -112,14 +114,14 @@
|
||||
#
|
||||
#statusbar_visibility = "yes"
|
||||
#
|
||||
#fancy_scrolling = "yes"
|
||||
#
|
||||
#enable_window_title = "yes"
|
||||
#
|
||||
##### colors definitions #####
|
||||
#
|
||||
#colors_enabled = "yes"
|
||||
#
|
||||
#fancy_scrolling = "yes"
|
||||
#
|
||||
#empty_tag_color = "cyan"
|
||||
#
|
||||
#header_window_color = "default"
|
||||
|
||||
@@ -2090,39 +2090,44 @@ int main(int argc, char *argv[])
|
||||
block_progressbar_update = 1;
|
||||
LockStatusbar();
|
||||
|
||||
int songpos, in;
|
||||
int songpos;
|
||||
time_t t = time(NULL);
|
||||
|
||||
songpos = Mpd->GetElapsedTime();
|
||||
Song &s = mPlaylist->at(now_playing);
|
||||
|
||||
while (1)
|
||||
while (Keypressed(input, Key.SeekForward) || Keypressed(input, Key.SeekBackward))
|
||||
{
|
||||
TraceMpdStatus();
|
||||
timer = time(NULL);
|
||||
mPlaylist->ReadKey(in);
|
||||
if (Keypressed(in, Key.SeekForward) || Keypressed(in, Key.SeekBackward))
|
||||
mPlaylist->ReadKey(input);
|
||||
|
||||
int howmuch = Config.incremental_seeking ? (timer-t)/2+1 : 1;
|
||||
|
||||
if (songpos < s.GetTotalLength() && Keypressed(input, Key.SeekForward))
|
||||
{
|
||||
if (songpos < s.GetTotalLength() && Keypressed(in, Key.SeekForward))
|
||||
songpos++;
|
||||
if (songpos < s.GetTotalLength() && songpos > 0 && Keypressed(in, Key.SeekBackward))
|
||||
songpos--;
|
||||
songpos += howmuch;
|
||||
if (songpos > s.GetTotalLength())
|
||||
songpos = s.GetTotalLength();
|
||||
}
|
||||
if (songpos < s.GetTotalLength() && songpos > 0 && Keypressed(input, Key.SeekBackward))
|
||||
{
|
||||
songpos -= howmuch;
|
||||
if (songpos < 0)
|
||||
songpos = 0;
|
||||
|
||||
wFooter->Bold(1);
|
||||
string tracklength = "[" + Song::ShowTime(songpos) + "/" + s.GetLength() + "]";
|
||||
wFooter->WriteXY(wFooter->GetWidth()-tracklength.length(), 1, tracklength);
|
||||
double progressbar_size = (double)songpos/(s.GetTotalLength());
|
||||
int howlong = wFooter->GetWidth()*progressbar_size;
|
||||
|
||||
mvwhline(wFooter->RawWin(), 0, 0, 0, wFooter->GetWidth());
|
||||
mvwhline(wFooter->RawWin(), 0, 0, '=',howlong);
|
||||
mvwaddch(wFooter->RawWin(), 0, howlong, '>');
|
||||
wFooter->Bold(0);
|
||||
wFooter->Refresh();
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
wFooter->Bold(1);
|
||||
string tracklength = "[" + Song::ShowTime(songpos) + "/" + s.GetLength() + "]";
|
||||
wFooter->WriteXY(wFooter->GetWidth()-tracklength.length(), 1, tracklength);
|
||||
double progressbar_size = (double)songpos/(s.GetTotalLength());
|
||||
int howlong = wFooter->GetWidth()*progressbar_size;
|
||||
|
||||
mvwhline(wFooter->RawWin(), 0, 0, 0, wFooter->GetWidth());
|
||||
mvwhline(wFooter->RawWin(), 0, 0, '=',howlong);
|
||||
mvwaddch(wFooter->RawWin(), 0, howlong, '>');
|
||||
wFooter->Bold(0);
|
||||
wFooter->Refresh();
|
||||
}
|
||||
Mpd->Seek(songpos);
|
||||
|
||||
|
||||
@@ -185,6 +185,7 @@ void DefaultConfiguration(ncmpcpp_config &conf)
|
||||
conf.wrapped_search = true;
|
||||
conf.space_selects = false;
|
||||
conf.albums_in_tag_editor = false;
|
||||
conf.incremental_seeking = true;
|
||||
conf.set_window_title = true;
|
||||
conf.mpd_connection_timeout = 15;
|
||||
conf.crossfade_time = 5;
|
||||
@@ -564,6 +565,10 @@ void ReadConfiguration(ncmpcpp_config &conf)
|
||||
{
|
||||
conf.albums_in_tag_editor = v == "albums";
|
||||
}
|
||||
else if (it->find("incremental_seeking") != string::npos)
|
||||
{
|
||||
conf.incremental_seeking = v == "yes";
|
||||
}
|
||||
else if (it->find("enable_window_title") != string::npos)
|
||||
{
|
||||
conf.set_window_title = v == "yes";
|
||||
|
||||
@@ -134,6 +134,7 @@ struct ncmpcpp_config
|
||||
bool wrapped_search;
|
||||
bool space_selects;
|
||||
bool albums_in_tag_editor;
|
||||
bool incremental_seeking;
|
||||
|
||||
int mpd_connection_timeout;
|
||||
int crossfade_time;
|
||||
|
||||
Reference in New Issue
Block a user