MphpD
v1.2.6
MphpD 、ミュージック プレーヤー デーモンのライブラリです。これにより、PHP アプリケーション内からシンプルかつオブジェクト指向の方法で MPD を制御できると同時に、エスケープ、解析、エラー報告、その他すべての面倒な作業も処理できます。
MPD プロトコル全体がサポートされています。
警告
このライブラリとそのドキュメントはかなり新しいため、完璧ではありません。
発生したバグや問題はここで報告してください。ありがとう。
このライブラリは、composer を使用してインストールできます。
composer require flofaber/ MphpD
そしてそれを自動ロードします:
require_once __DIR__ . " /vendor/autoload.php " ;
または、次のようにダウンロードしてコードに含めることもできます。
require_once __DIR__ . " / MphpD / MphpD .php " ;
新しいMphpDインスタンスを作成します。
use FloFaber MphpD MphpD ;
use FloFaber MphpD MPDException ;
$ MphpD = new MphpD ([
" host " => " 127.0.0.1 " ,
" port " => 6600 ,
" timeout " => 5
]);
MPDに接続します
try {
$ MphpD -> connect ();
} catch ( MPDException $ e ){
echo $ e -> getMessage ();
return false ;
}
これを使用して何ができるかの例をいくつか示します。
// get MPD's status like current song, volume, state, etc...
$ status = $ MphpD -> status ();
// if you only want to retrieve only one (or more) values
// you can pass it a list of keys.
$ state = $ MphpD -> status ([ " state " ]);
// clear the queue
$ MphpD -> queue ()-> clear ();
// load the first 10 songs of a playlist into the queue and exit on failure.
if (! $ MphpD -> playlist ( " some-playlist " )-> load ([ 0 , 10 ])){
echo $ MphpD -> get_last_error ()[ " message " ]; // prints "No such playlist"
return false ;
}
// shuffle the queue
$ MphpD -> queue ()-> shuffle ();
// adjust volume to 40%
$ MphpD -> player ()-> volume ( 40 );
// start playing
$ MphpD -> player ()-> play ();
詳細については、ドキュメントを参照してください。
sockets
のみ。 MphpDがソケット通信に必要とする PHP 関数のリスト:
fgets
fputs
fread
stream_get_meta_data
stream_set_chunk_size
stream_set_timeout
stream_socket_client