fix(mpd) Support relative seek percentages

This commit is contained in:
Michael Carlberg 2016-05-20 05:34:07 +02:00
parent 20934b9316
commit c7b6554668
2 changed files with 15 additions and 1 deletions
src/modules

View file

@ -290,9 +290,19 @@ bool MpdModule::handle_command(const std::string& cmd)
mpd->random(true);
else if (cmd.find(EVENT_SEEK) == 0) {
auto s = cmd.substr(std::strlen(EVENT_SEEK));
int perc = 0;
if (s.empty())
return false;
mpd->seek(std::atoi(s.c_str()));
if (s[0] == '+') {
perc = this->status->get_elapsed_percentage()
+ std::atoi(s.substr(1).c_str());
} else if (s[0] == '-') {
perc = this->status->get_elapsed_percentage()
- std::atoi(s.substr(1).c_str());
} else {
perc = std::atoi(s.c_str());
}
mpd->seek(perc);
} else
return false;
} catch (mpd::Exception &e) {