| | 535 | static void nextSong() |
| | 536 | { |
| | 537 | mpd_update(); |
| | 538 | if (currentSong != NULL) { |
| | 539 | mpd_sendNextCommand(conn); |
| | 540 | mpd_finishCommand(conn); |
| | 541 | if (conn->error) { |
| | 542 | error("[MPD] error mpd_finishCommand: %s", conn->errorStr); |
| | 543 | } |
| | 544 | } |
| | 545 | } |
| | 546 | |
| | 547 | static void prevSong() |
| | 548 | { |
| | 549 | mpd_update(); |
| | 550 | if (currentSong != NULL) { |
| | 551 | mpd_sendPrevCommand(conn); |
| | 552 | mpd_finishCommand(conn); |
| | 553 | if (conn->error) { |
| | 554 | error("[MPD] error mpd_finishCommand: %s", conn->errorStr); |
| | 555 | } |
| | 556 | } |
| | 557 | } |
| | 558 | |
| | 559 | static void stopSong() |
| | 560 | { |
| | 561 | mpd_update(); |
| | 562 | if (currentSong != NULL) { |
| | 563 | mpd_sendStopCommand(conn); |
| | 564 | mpd_finishCommand(conn); |
| | 565 | if (conn->error) { |
| | 566 | error("[MPD] error mpd_finishCommand: %s", conn->errorStr); |
| | 567 | } |
| | 568 | } |
| | 569 | } |
| | 570 | |
| | 571 | static void pauseSong() |
| | 572 | { |
| | 573 | mpd_update(); |
| | 574 | if (currentSong != NULL) { |
| | 575 | if (l_state == MPD_STATUS_STATE_PAUSE) { |
| | 576 | mpd_sendPauseCommand(conn, 0); |
| | 577 | } else { |
| | 578 | mpd_sendPauseCommand(conn, 1); |
| | 579 | } |
| | 580 | |
| | 581 | mpd_finishCommand(conn); |
| | 582 | if (conn->error) { |
| | 583 | error("[MPD] error mpd_finishCommand: %s", conn->errorStr); |
| | 584 | } |
| | 585 | } |
| | 586 | } |
| | 587 | |
| | 588 | static void volUp() |
| | 589 | { |
| | 590 | mpd_update(); |
| | 591 | if (currentSong != NULL) { |
| | 592 | l_volume += 5; |
| | 593 | if (l_volume > 100) |
| | 594 | l_volume=100; |
| | 595 | mpd_sendSetvolCommand(conn, l_volume); |
| | 596 | mpd_finishCommand(conn); |
| | 597 | if (conn->error) { |
| | 598 | error("[MPD] error mpd_finishCommand: %s", conn->errorStr); |
| | 599 | } |
| | 600 | } |
| | 601 | } |
| | 602 | |
| | 603 | static void volDown() |
| | 604 | { |
| | 605 | mpd_update(); |
| | 606 | if (currentSong != NULL) { |
| | 607 | if (l_volume > 5) |
| | 608 | l_volume -= 5; |
| | 609 | else |
| | 610 | l_volume = 0; |
| | 611 | mpd_sendSetvolCommand(conn, l_volume); |
| | 612 | mpd_finishCommand(conn); |
| | 613 | if (conn->error) { |
| | 614 | error("[MPD] error mpd_finishCommand: %s", conn->errorStr); |
| | 615 | } |
| | 616 | } |
| | 617 | } |
| | 618 | |
| | 619 | static void toggleRepeat() |
| | 620 | { |
| | 621 | mpd_update(); |
| | 622 | if (currentSong != NULL) { |
| | 623 | |
| | 624 | l_repeatEnabled = !l_repeatEnabled; |
| | 625 | mpd_sendRepeatCommand(conn, l_repeatEnabled); |
| | 626 | |
| | 627 | mpd_finishCommand(conn); |
| | 628 | if (conn->error) { |
| | 629 | error("[MPD] error mpd_finishCommand: %s", conn->errorStr); |
| | 630 | } |
| | 631 | } |
| | 632 | } |
| | 633 | |
| | 634 | |
| | 635 | static void toggleRandom() |
| | 636 | { |
| | 637 | mpd_update(); |
| | 638 | if (currentSong != NULL) { |
| | 639 | |
| | 640 | l_randomEnabled = !l_randomEnabled; |
| | 641 | mpd_sendRandomCommand(conn, l_randomEnabled); |
| | 642 | |
| | 643 | mpd_finishCommand(conn); |
| | 644 | if (conn->error) { |
| | 645 | error("[MPD] error mpd_finishCommand: %s", conn->errorStr); |
| | 646 | } |
| | 647 | } |
| | 648 | } |
| | 649 | |
| | 730 | AddFunction("mpd::cmdNextSong", 0, nextSong); |
| | 731 | AddFunction("mpd::cmdPrevSong", 0, prevSong); |
| | 732 | AddFunction("mpd::cmdStopSong", 0, stopSong); |
| | 733 | AddFunction("mpd::cmdTogglePauseSong", 0, pauseSong); |
| | 734 | AddFunction("mpd::cmdVolUp", 0, volUp); |
| | 735 | AddFunction("mpd::cmdVolDown", 0, volDown); |
| | 736 | AddFunction("mpd::cmdToggleRandom", 0, toggleRandom); |
| | 737 | AddFunction("mpd::cmdToggleRepeat", 0, toggleRepeat); |
| | 738 | |