jetzt habe ich eine weile aus dem forum genommen, nun möchte ich was zurück geben : ) vielleicht kanns ja jemand brauchen.
habt nachsicht mit mir, php ist für mich eine NEUE sprache.
ich musste div. anpassungen vornehmen, liegt wohl an der aktuellen ips-version:
- IPS_SetVariableProfileAssociation($profil.‚2‘,$i+1,$files2[$i],"", 0xFF0000);
- Association´s leider jetzt auf 30 begrenzt SEHR SCHADE (alternative?)
- …
… ausserdem können jetzt auch umlaute in den ordnernamen gelesen werden
- da meine mp3´s auf einem server liegen muss ich leider einen umweg über ein synch-batch gehen, hab schon im forum gesucht, es gab div. tipps mit /// \\ etc… hat aber nichts funktioniert, scheint eine php-krankheit zu sein
Kennt einer DIE lösung?
Mp3-Play:
<?
$dir = 'E:/myMusic/';
$dir = '\\K1NG-SERVER\Musik';
$dir = 'D:/_MP3/';
$dir_le = strlen($dir);
$Mp3ordner = GetValueString(46281 /*[IPSAMP\MP3String]*/);
$temp_array = wddx_deserialize($Mp3ordner);
$id_sound = 20686 /*[IPSAMP\Media Player]*/;
////////////////////////////////////////////////////////////////////////////////
if( ! ( $dh = @opendir( $dir ) ) ) //löschen
{
// Fehler handeln...
}
while( ( $dirent = readdir( $dh ) ) !== false )
{
$abs_dirent = $dir.$dirent;
if( $dirent != '.' && $dirent != '..' && is_dir( $abs_dirent ) )
{
$files[] = $abs_dirent;
}
}
closedir( $dh );
////////////////////////////////////////////////////////////////////////////////
$i=0;
foreach ($files as $i => $val) {
$files2[$i] = substr($val,$dir_le);
}
////////////////////////////////////////////////////////////////////////////////
$data = array("0" => "ResetDisplayWebfront");
$files = array();
$i=0;
$j=0;
foreach ($files2 as $files2[$i]) {
//if(($files[$i] <> ".") AND ($files[$i] <> ".."))
array_push ( $files, utf8_encode($files2[$i]) );
// array_push ( $files, utf8_decode($files2[$i]) );
$j++;
}
////////////////////////////////////////////////////////////////////////////////
WAC_PlayDir($id_sound,$dir.$temp_array[$ordn]);
function WAC_PlayDir($id, $dir)
{
function ReadRecursive($dir, $subdir = "") {
$result = Array();
$files = scandir($dir."/".$subdir);
foreach($files as $file)
{
if(($file != ".") && ($file != "..")){
if(is_dir($dir."/".$subdir."/".$file)) {
$res = ReadRecursive($dir, $subdir."/".$file);
$result = array_merge($res, $result);
} else {
$filedir = $subdir."/".$file;
$filedir = substr($filedir, 1, strlen($filedir));
$result[] = $filedir;
}
}
}
return $result;
}
$allowed = Array("mp3", "wma");
$files = ReadRecursive($dir);
//Den Zufallsgenerator von PHP verwenden
//shuffle($files);
WAC_ClearPlaylist($id);
foreach($files as $file)
{
$ext = pathinfo($dir."/".$file, PATHINFO_EXTENSION);
if(in_array(strtolower($ext), $allowed))
{
WAC_AddFile($id, $dir."/".$file);
}
}
WAC_Play($id);
}
//print_r($temp_array);
//print_r($files);
?>
Folder-Read:
<?
$dir = 'E:/myMusic/';
$dir = '\\K1NG-SERVER\Musik';
$dir = 'D:/_MP3/';
//$dir = '192.168.178.20/music/';
//\\\\MEIN_SERVER\\FREIGABE\\
//$dir = '\\\\K1NG-SERVER\\Musik\\)';
$dir_le = strlen($dir);
$files = array();
$profil = "Musikordner";
////////////////////////////////////////////////////////////////////////////////
if( ! ( $dh = @opendir( $dir ) ) ) //löschen
{
// print_r($dir);
}
while( ( $dirent = readdir( $dh ) ) !== false )
{
$abs_dirent = $dir.$dirent;
if( $dirent != '.' && $dirent != '..' && is_dir( $abs_dirent ) )
{
$files[] = $abs_dirent;
}
}
closedir( $dh );
////////////////////////////////////////////////////////////////////////////////
$many = count($files);
$anz_arr= round(($many/30)+0.499);
////////////////////////////////////////////////////////////////////////////////
$i=0;
foreach ($files as $i => $val) {
$files2[$i] = substr($val,$dir_le);
}
////////////////////////////////////////////////////////////////////////////////
IPS_DeleteVariableProfile($profil);
IPS_CreateVariableProfile($profil,1);
IPS_SetVariableCustomProfile(19877 /*[IPSAMP\MP3]*/,$profil);//41184
for ($i=0;$i < ($many);$i++)
if ($i <= 30)
IPS_SetVariableProfileAssociation($profil,$i+1,$files2[$i],"", 0xFF0000);
if (($anz_arr > 1) AND ($anz_arr <> 1) AND ($i > 30))
IPS_DeleteVariableProfile($profil.'2');
IPS_CreateVariableProfile($profil.'2',1);
IPS_SetVariableCustomProfile(17845 /*[IPSAMP\MP3II]*/,$profil.'2');//41184
for ($i=0;$i < $many;$i++)
if ($i > 30)
IPS_SetVariableProfileAssociation($profil.'2',$i+1,$files2[$i],"", 0xFF0000);
////////////////////////////////////////////////////////////////////////////////
$data = array("0" => "ResetDisplayWebfront");
$i=0;
$j=0;
foreach ($files2 as $files2[$i]) {
//if(($files[$i] <> ".") AND ($files[$i] <> ".."))
array_push ( $data, utf8_encode($files2[$i]) );
$j++;
}
////////////////////////////////////////////////////////////////////////////////
SetValueString(46281 /*[IPSAMP\MP3String]*/, wddx_serialize_value($data));
//print_r($j);
//print_r($many);
print_r($anz_arr);
print_r($files);
?>
SetFolderWebfront:
<?
if ($IPS_VALUE <= 30) {
setvalue(17845 /*[IPSAMP\MP3II]*/,0);
setvalue(19877 /*[IPSAMP\MP3]*/,$IPS_VALUE);
}
if ($IPS_VALUE > 30) {
setvalue(19877 /*[IPSAMP\MP3]*/,0);
setvalue(17845 /*[IPSAMP\MP3II]*/,$IPS_VALUE);
}
IPS_RunScriptEx(55414 /*[IPSAMP\Mp3Play]*/,Array("ordn" => $IPS_VALUE));
?>