MphpD
v1.2.6
MphpD เป็นไลบรารีสำหรับ Music Player Daemon มันช่วยให้คุณควบคุม MPD จากภายในแอปพลิเคชัน PHP ของคุณด้วยวิธีที่เรียบง่ายและเน้นเชิงวัตถุ ในขณะเดียวกันก็ดูแลการ Escape การแยกวิเคราะห์ การรายงานข้อผิดพลาด และปัญหาอื่นๆ ทั้งหมด
รองรับโปรโตคอล 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
ที่รวมอยู่ในการติดตั้ง PHP ส่วนใหญ่โดยค่าเริ่มต้น รายการฟังก์ชัน PHP ที่ MphpD ต้องการสำหรับการสื่อสารซ็อกเก็ต:
fgets
fputs
fread
stream_get_meta_data
stream_set_chunk_size
stream_set_timeout
stream_socket_client