add option added + a few fixes regarding tracks with unknown length
This commit is contained in:
@@ -153,6 +153,11 @@ string TotalPlaylistLength()
|
||||
for (SongList::const_iterator it = vPlaylist.begin(); it != vPlaylist.end(); it++)
|
||||
length += (*it)->GetTotalLength();
|
||||
|
||||
if (!length)
|
||||
return result;
|
||||
|
||||
result += ", length: ";
|
||||
|
||||
int years = length/YEAR;
|
||||
if (years)
|
||||
{
|
||||
|
||||
@@ -256,6 +256,7 @@ int main(int argc, char *argv[])
|
||||
sHelp->Add(DisplayKeys(Key.Crop) + "Clear playlist but hold currently playing song\n");
|
||||
sHelp->Add(DisplayKeys(Key.MvSongUp) + "Move song up\n");
|
||||
sHelp->Add(DisplayKeys(Key.MvSongDown) + "Move song down\n");
|
||||
sHelp->Add(DisplayKeys(Key.Add) + "Add url/file/directory to playlist\n");
|
||||
sHelp->Add(DisplayKeys(Key.SavePlaylist) + "Save playlist\n");
|
||||
sHelp->Add(DisplayKeys(Key.GoToNowPlaying) + "Go to currently playing position\n");
|
||||
sHelp->Add(DisplayKeys(Key.ToggleAutoCenter) + "Toggle auto center mode\n\n\n");
|
||||
@@ -1316,11 +1317,41 @@ int main(int argc, char *argv[])
|
||||
mPlaylist->Go(DOWN);
|
||||
}
|
||||
}
|
||||
else if (Keypressed(input, Key.Add))
|
||||
{
|
||||
LOCK_STATUSBAR;
|
||||
wFooter->WriteXY(0, Config.statusbar_visibility, "Add: ", 1);
|
||||
string path = wFooter->GetString("");
|
||||
UNLOCK_STATUSBAR;
|
||||
SongList list;
|
||||
Mpd->GetDirectoryRecursive(path, list);
|
||||
if (!list.empty())
|
||||
{
|
||||
for (SongList::const_iterator it = list.begin(); it != list.end(); it++)
|
||||
Mpd->QueueAddSong(**it);
|
||||
if (Mpd->CommitQueue())
|
||||
{
|
||||
Song *s = vPlaylist[vPlaylist.size()-list.size()];
|
||||
if (s->GetHash() != list[0]->GetHash())
|
||||
ShowMessage(message_part_of_songs_added);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!path.empty())
|
||||
Mpd->AddSong(path);
|
||||
}
|
||||
FreeSongList(list);
|
||||
}
|
||||
else if (Keypressed(input, Key.SeekForward) || Keypressed(input, Key.SeekBackward))
|
||||
{
|
||||
if (now_playing < 0)
|
||||
continue;
|
||||
|
||||
if (!vPlaylist[now_playing]->GetTotalLength())
|
||||
{
|
||||
ShowMessage("Unknown item length!");
|
||||
continue;
|
||||
}
|
||||
block_progressbar_update = 1;
|
||||
LOCK_STATUSBAR;
|
||||
|
||||
@@ -1442,12 +1473,15 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (now_playing < 0)
|
||||
continue;
|
||||
int newpos = 0;
|
||||
string position;
|
||||
if (!vPlaylist[now_playing]->GetTotalLength())
|
||||
{
|
||||
ShowMessage("Unknown item length!");
|
||||
continue;
|
||||
}
|
||||
LOCK_STATUSBAR;
|
||||
wFooter->WriteXY(0, Config.statusbar_visibility, "Position to go (in %): ", 1);
|
||||
position = wFooter->GetString(3, TraceMpdStatus);
|
||||
newpos = atoi(position.c_str());
|
||||
string position = wFooter->GetString(3, TraceMpdStatus);
|
||||
int newpos = atoi(position.c_str());
|
||||
if (newpos > 0 && newpos < 100 && !position.empty())
|
||||
Mpd->Seek(vPlaylist[now_playing]->GetTotalLength()*newpos/100.0);
|
||||
UNLOCK_STATUSBAR;
|
||||
|
||||
@@ -67,6 +67,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
||||
keys.Crop[0] = 'C';
|
||||
keys.MvSongUp[0] = 'm';
|
||||
keys.MvSongDown[0] = 'n';
|
||||
keys.Add[0] = 'a';
|
||||
keys.SavePlaylist[0] = 'S';
|
||||
keys.GoToNowPlaying[0] = 'o';
|
||||
keys.ToggleAutoCenter[0] = 'U';
|
||||
@@ -113,6 +114,7 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
||||
keys.Crop[1] = null_key;
|
||||
keys.MvSongUp[1] = null_key;
|
||||
keys.MvSongDown[1] = null_key;
|
||||
keys.Add[1] = null_key;
|
||||
keys.SavePlaylist[1] = null_key;
|
||||
keys.GoToNowPlaying[1] = null_key;
|
||||
keys.ToggleAutoCenter[1] = null_key;
|
||||
@@ -123,8 +125,8 @@ void DefaultKeys(ncmpcpp_keys &keys)
|
||||
void DefaultConfiguration(ncmpcpp_config &conf)
|
||||
{
|
||||
conf.mpd_music_dir = "/var/lib/mpd/music";
|
||||
conf.song_list_format = "[green](%l)[/green] {%a - }{%t}|{[white]%f[/white]}";
|
||||
conf.song_status_format = "(%l) {%a - }{%t}|{%f}";
|
||||
conf.song_list_format = "{[green](%l)[/green] }{%a - }{%t}|{[white]%f[/white]}";
|
||||
conf.song_status_format = "{(%l) }{%a - }{%t}|{%f}";
|
||||
conf.song_window_title_format = "{%a - }{%t}|{%f}";
|
||||
conf.song_library_format = "{%n - }{%t}|{%f}";
|
||||
conf.browser_playlist_prefix = "[red](playlist)[/red] ";
|
||||
@@ -337,6 +339,8 @@ void ReadKeys(ncmpcpp_keys &keys)
|
||||
GetKeys(*it, keys.MvSongUp);
|
||||
else if (it->find("key_move_song_down ") != string::npos)
|
||||
GetKeys(*it, keys.MvSongDown);
|
||||
else if (it->find("key_add ") != string::npos)
|
||||
GetKeys(*it, keys.Add);
|
||||
else if (it->find("key_save_playlist ") != string::npos)
|
||||
GetKeys(*it, keys.SavePlaylist);
|
||||
else if (it->find("key_go_to_now_playing ") != string::npos)
|
||||
|
||||
@@ -69,6 +69,7 @@ struct ncmpcpp_keys
|
||||
int Crop[2];
|
||||
int MvSongUp[2];
|
||||
int MvSongDown[2];
|
||||
int Add[2];
|
||||
int SavePlaylist[2];
|
||||
int GoToNowPlaying[2];
|
||||
int ToggleAutoCenter[2];
|
||||
|
||||
@@ -56,7 +56,7 @@ class Song
|
||||
string GetComment() const;
|
||||
string GetLength() const;
|
||||
long long GetHash() const { return itsHash; }
|
||||
int GetTotalLength() const { return itsMinutesLength*60+itsSecondsLength; }
|
||||
int GetTotalLength() const { return itsSecondsLength < 0 ? 0 : itsMinutesLength*60+itsSecondsLength; }
|
||||
int GetMinutesLength() const { return itsMinutesLength; }
|
||||
int GetSecondsLength() const { return itsSecondsLength; }
|
||||
int GetPosition() const { return itsPosition; }
|
||||
|
||||
@@ -225,7 +225,7 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da
|
||||
ShowMessage("Cleared playlist!");
|
||||
}
|
||||
else
|
||||
playlist_stats = "(" + IntoStr(vPlaylist.size()) + (vPlaylist.size() == 1 ? " song" : " songs") + ", length: " + TotalPlaylistLength() + ")";
|
||||
playlist_stats = "(" + IntoStr(vPlaylist.size()) + (vPlaylist.size() == 1 ? " item" : " items") + TotalPlaylistLength() + ")";
|
||||
|
||||
if (current_screen == csBrowser)
|
||||
{
|
||||
@@ -357,7 +357,7 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da
|
||||
if (!block_statusbar_update && Config.statusbar_visibility)
|
||||
{
|
||||
string tracklength;
|
||||
if (s.GetTotalLength() > 0)
|
||||
if (s.GetTotalLength())
|
||||
tracklength = " [" + ShowTime(elapsed) + "/" + s.GetLength() + "]";
|
||||
else
|
||||
tracklength = " [" + ShowTime(elapsed) + "]";
|
||||
@@ -390,12 +390,15 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da
|
||||
}
|
||||
if (!block_progressbar_update)
|
||||
{
|
||||
double progressbar_size = (double)elapsed/(s.GetMinutesLength()*60+s.GetSecondsLength());
|
||||
double progressbar_size = (double)elapsed/(s.GetTotalLength());
|
||||
int howlong = wFooter->GetWidth()*progressbar_size;
|
||||
wFooter->SetColor(Config.progressbar_color);
|
||||
mvwhline(wFooter->RawWin(), 0, 0, 0, wFooter->GetWidth());
|
||||
mvwhline(wFooter->RawWin(), 0, 0, '=',howlong);
|
||||
mvwaddch(wFooter->RawWin(), 0, howlong, '>');
|
||||
if (s.GetTotalLength())
|
||||
{
|
||||
mvwhline(wFooter->RawWin(), 0, 0, '=',howlong);
|
||||
mvwaddch(wFooter->RawWin(), 0, howlong, '>');
|
||||
}
|
||||
wFooter->SetColor(Config.statusbar_color);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user