AudioCast M5 stream music from linux/windows

blaszczakm.blogspot.com 2 lat temu

1) set music:
http://192.168.51.173/httpapi.asp?command=setPlayerCmd:play:http://192.168.51.5/music/mata.mp3

2) loop(1)/or noloop(0)
http://192.168.51.173/httpapi.asp?command=setPlayerCmd:loopmode:1


3) listen radio internet

http://192.168.51.173/httpapi.asp?command=setPlayerCmd:play:http://pr320.pinguinradio.nl/listen.pls


https://github.com/AndersFluur/LinkPlayApi/blob/master/api.md


Stworzyłem skrypt, który sprawdza czy urządzenie jest włączone do prądu i jeżeli jest to ma włączyć muzyke - do wykorzystania w inteligentnych domach.






cat playmusic.php
<?php
$ip = "192.168.51.173";
while(1){
$ping = exec("ping -c 1 -s 64 -t 64 ".$ip);
if(!empty($ping))
{
// Initiate curl session
$handle = curl_init();
// Will return the response, if false it prints the response
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
// Set the url
$url = "http://$ip/httpapi.asp?command=getPlayerStatus";
curl_setopt($handle, CURLOPT_URL,$url);
// Execute the session and store the contents in $result
$result=curl_exec($handle);
// Closing the session
curl_close($handle);
$array = json_decode($result, true);
// var_dump($array);

if($array['Title']=='556E6B6E6F776E') // czyli jesli jest ten hash to nie gra
{
echo 'nie gra'; // wiec trzeba puscic muzyke
// Initiate curl session
$handle = curl_init();
// Will return the response, if false it prints the response
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
// Set the url
$url_radio = "http://$ip/httpapi.asp?command=setPlayerCmd:play:http://pr320.pinguinradio.nl/listen.pls";
curl_setopt($handle, CURLOPT_URL,$url_radio);
// Execute the session and store the contents in $result
$result=curl_exec($handle);
// Closing the session
curl_close($handle);
}
else
{
echo 'gra'; // gra radio wiec nic juz nie robie :) czekam
sleep(10);
}
}
}
Idź do oryginalnego materiału