smt/pmpd

PHP 音乐播放器守护进程控制实现

v1.0.0 2015-12-02 09:09 UTC

This package is not auto-updated.

Last update: 2024-09-14 17:59:01 UTC


README

PHP 客户端库用于音乐播放器守护进程

先决条件

  • PHP 5.6+
  • 运行 MPD :)

安装

composer require smt/pmpd dev-develop

用法

use Smt\Pmpd\Client\Impl\DefaultClient;
use Smt\Pmpd\Configuration\HostConfiguration;
use Smt\Pmpd\Connection\Commands;
use Smt\Pmpd\Connection\ConnectionFactory;
use Smt\Pmpd\Entity\Enum\PlaybackState;
use Smt\Pmpd\Response\FailResponse;

$connectionFactory = new ConnectionFactory();
$config = new HostConfiguration();
$config->setHost('127.0.0.1');
$connection = $connectionFactory->createConnection($config);
$client = new DefaultClient($connection);

echo $client->getCurrent()->getTitle() . ' playing: ';
echo $client->getStatus()->getState() == PlaybackState::PLAYING . PHP_EOL;
$client->next();
$client->toggle();
$client->play();
$client->updateDatabaseAsync();
$response = $client->query(Commands::ADD_AND_RETURN_ID, 'Asking Alexandria - Not The American Average.flac', 1); // Add it to first position
if ($response instanceof FailResponse) {
    echo 'Something gone wrong :(' . PHP_EOL . PHP_EOL . $response->getMessage();
} else {
    echo 'Id in playlist:' . $response->get('Id') . PHP_EOL;
}

更多信息请参阅文档

路线图

  • 实现带密码的连接;
  • 编写 API 文档;
  • 用测试覆盖;
  • 重写客户端到子系统外观;

许可证

本库受MIT 许可证许可。