add MPD::Connection::Toggle() and throw away MPD::Connection::Execute()
This commit is contained in:
@@ -163,24 +163,12 @@ void ParseArgv(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
else if (!strcmp(argv[i], "pause"))
|
else if (!strcmp(argv[i], "pause"))
|
||||||
{
|
{
|
||||||
Mpd.Execute("pause \"1\"\n");
|
Mpd.Pause(1);
|
||||||
quit = 1;
|
quit = 1;
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[i], "toggle"))
|
else if (!strcmp(argv[i], "toggle"))
|
||||||
{
|
{
|
||||||
Mpd.UpdateStatus();
|
Mpd.Toggle();
|
||||||
switch (Mpd.GetState())
|
|
||||||
{
|
|
||||||
case psPause:
|
|
||||||
case psPlay:
|
|
||||||
Mpd.Pause();
|
|
||||||
break;
|
|
||||||
case psStop:
|
|
||||||
Mpd.Play();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
quit = 1;
|
quit = 1;
|
||||||
}
|
}
|
||||||
else if (!strcmp(argv[i], "stop"))
|
else if (!strcmp(argv[i], "stop"))
|
||||||
|
|||||||
@@ -204,14 +204,6 @@ bool Connection::UpdateDirectory(const std::string &path)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Connection::Execute(const std::string &command) const
|
|
||||||
{
|
|
||||||
if (!isConnected)
|
|
||||||
return false;
|
|
||||||
mpd_send_command(itsConnection, command.c_str());
|
|
||||||
return isCommandsListEnabled || mpd_response_finish(itsConnection);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Connection::Play() const
|
void Connection::Play() const
|
||||||
{
|
{
|
||||||
if (!isConnected)
|
if (!isConnected)
|
||||||
@@ -233,7 +225,14 @@ void Connection::PlayID(int id) const
|
|||||||
(isCommandsListEnabled ? mpd_send_play_id : mpd_run_play_id)(itsConnection, id);
|
(isCommandsListEnabled ? mpd_send_play_id : mpd_run_play_id)(itsConnection, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Connection::Pause() const
|
void Connection::Pause(bool state) const
|
||||||
|
{
|
||||||
|
if (!isConnected)
|
||||||
|
return;
|
||||||
|
(isCommandsListEnabled ? mpd_send_pause : mpd_run_pause)(itsConnection, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Connection::Toggle() const
|
||||||
{
|
{
|
||||||
if (!isConnected)
|
if (!isConnected)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -103,12 +103,11 @@ namespace MPD
|
|||||||
void UpdateStatus();
|
void UpdateStatus();
|
||||||
bool UpdateDirectory(const std::string &);
|
bool UpdateDirectory(const std::string &);
|
||||||
|
|
||||||
bool Execute(const std::string &) const;
|
|
||||||
|
|
||||||
void Play() const;
|
void Play() const;
|
||||||
void Play(int) const;
|
void Play(int) const;
|
||||||
void PlayID(int) const;
|
void PlayID(int) const;
|
||||||
void Pause() const;
|
void Pause(bool) const;
|
||||||
|
void Toggle() const;
|
||||||
void Stop() const;
|
void Stop() const;
|
||||||
void Next() const;
|
void Next() const;
|
||||||
void Prev() const;
|
void Prev() const;
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ int main(int argc, char *argv[])
|
|||||||
&& mouse_event.y == (Config.new_design ? 1 : LINES-1) && mouse_event.x < 9
|
&& mouse_event.y == (Config.new_design ? 1 : LINES-1) && mouse_event.x < 9
|
||||||
) // playing/paused
|
) // playing/paused
|
||||||
{
|
{
|
||||||
Mpd.Pause();
|
Mpd.Toggle();
|
||||||
UpdateStatusImmediately = 1;
|
UpdateStatusImmediately = 1;
|
||||||
}
|
}
|
||||||
else if ((mouse_event.bstate & BUTTON2_PRESSED || mouse_event.bstate & BUTTON4_PRESSED)
|
else if ((mouse_event.bstate & BUTTON2_PRESSED || mouse_event.bstate & BUTTON4_PRESSED)
|
||||||
@@ -722,7 +722,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else if (Keypressed(input, Key.Pause))
|
else if (Keypressed(input, Key.Pause))
|
||||||
{
|
{
|
||||||
Mpd.Pause();
|
Mpd.Toggle();
|
||||||
UpdateStatusImmediately = 1;
|
UpdateStatusImmediately = 1;
|
||||||
}
|
}
|
||||||
else if (Keypressed(input, Key.SavePlaylist))
|
else if (Keypressed(input, Key.SavePlaylist))
|
||||||
|
|||||||
Reference in New Issue
Block a user