MphpD
v1.2.6
MphpD Music Player Daemon용 라이브러리입니다. 이를 통해 PHP 애플리케이션 내에서 간단하고 객체 지향적인 방식으로 MPD를 제어하는 동시에 이스케이프, 구문 분석, 오류 보고 및 기타 모든 어려운 작업을 처리할 수 있습니다.
전체 MPD 프로토콜이 지원됩니다!
경고
이 라이브러리와 문서는 다소 젊기 때문에 완벽하지 않습니다.
버그나 문제가 발견되면 여기에 보고해 주세요. 감사해요.
작곡가를 사용하여 이 라이브러리를 설치할 수 있습니다.
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