public function current() { return parent::isFile() ? parent::getSize() : 0; }
private function PlayListFromDir($Dir, &$Key, &$Playlist, &$Info) { global $NL; global $DIR_DELIM; $Arr = new ArrayObject(); try { $cnt = 0; $MTimeDPL = -1; $MaxMTimeMusic = -1; $it = new directoryIterator($Dir); while ($it->valid()) { if ($it->isFile()) { $ext = pathinfo($it->current(), PATHINFO_EXTENSION); if ($ext == "dpl") { $MTimeDPL = $it->getMTime(); } elseif ($ext == "flac" || $ext == "mp3" || $ext == "wma" || $ext == "m4a") { if ($MaxMTimeMusic == -1 || $MaxMTimeMusic < $it->getMTime()) { $MaxMTimeMusic = $it->getMTime(); } $cnt++; } } $it->next(); } if ($cnt == 0 || $MTimeDPL > 0 && $MTimeDPL > $MaxMTimeMusic) { return false; } $it->rewind(); while ($it->valid()) { if ($it->isFile()) { $ext = pathinfo($it->current(), PATHINFO_EXTENSION); if ($ext == "dpl") { unlink($it->getPathName()); } elseif ($ext == "flac" || $ext == "mp3" || $ext == "wma" || $ext == "m4a") { //echo $it->getPathName() . $NL; $Arr->append(new MusicTags($it->getPathName())); } } $it->next(); } } catch (Exception $e) { echo $e->getMessage(); } $Tracks = ""; $cnt = $Arr->count(); if ($cnt > 1) { $Arr->uasort(array('Playlist', 'TrackNoOrder')); } $it = $Arr->getIterator(); while ($it->valid()) { if (0 && isset($Artist) && $Artist != $it->current()->Artist()) { $Artist = "Various Artists"; $ARTIST = $Artist; } else { $Artist = str_replace("/", ",", $it->current()->Artist()); $ARTIST = $it->current()->Artist(); } $AlbumArtist = str_replace("/", ",", $it->current()->AlbumArtist()); $ALBUMARTIST = $it->current()->AlbumArtist(); $Album = str_replace("/", ",", $it->current()->Album()); $ALBUM = $it->current()->Album(); $Date = $it->current()->Date(); $DATE = $Date; $Genre = str_replace("/", ",", $it->current()->Genre()); $GENRE = $it->current()->Genre(); $Tracks .= $NL . Linn_Track($it->current()->getDIDL()); $it->next(); } if ($cnt > 0) { $PLAYLIST = RelativeBuildPath($Dir . $DIR_DELIM . "playlist.dpl"); $PLAYLIST = str_replace("&", "&", $PLAYLIST); $img = $Dir . $DIR_DELIM . "folder.png"; if (!file_exists($img)) { $img = $Dir . $DIR_DELIM . "folder.jpg"; } $ART = RelativeBuildPath($img); $img80 = dirname($img) . $DIR_DELIM . "80x80.jpg"; $img160 = dirname($img) . $DIR_DELIM . "160x160.jpg"; if (file_exists($img)) { if (!file_exists($img80)) { $cmd = 'convert "' . $img . '" -thumbnail 80x80 +profile "*" "' . $img80 . '"'; echo $NL . $cmd . $NL; shell_exec($cmd); } if (!file_exists($img160)) { $cmd = 'convert "' . $img . '" -thumbnail 160x160 +profile "*" "' . $img160 . '"'; echo $NL . $cmd . $NL; shell_exec($cmd); } } $ART80 = RelativeBuildPath($img80); $ART160 = RelativeBuildPath($img160); $ART = str_replace("&", "&", $ART); $ART80 = str_replace("&", "&", $ART80); $ART160 = str_replace("&", "&", $ART160); $ALBUM = str_replace("&", "&", $ALBUM); $GENRE = str_replace("&", "&", $GENRE); $ARTIST = str_replace("&", "&", $ARTIST); $ALBUMARTIST = str_replace("&", "&", $ALBUMARTIST); $ART = str_replace('"', """, $ART); $ART80 = str_replace('"', """, $ART80); $ART160 = str_replace('"', """, $ART160); $ALBUM = str_replace('"', """, $ALBUM); $GENRE = str_replace('"', """, $GENRE); $ARTIST = str_replace('"', """, $ARTIST); $Artist = str_replace('"', """, $Artist); $ALBUMARTIST = str_replace('"', """, $ALBUMARTIST); $AlbumArtist = str_replace('"', """, $AlbumArtist); $Key = $AlbumArtist . "+" . $Album . "+" . $Date . "+" . $Genre . "+" . $MaxMTimeMusic; //$KEY = $ALBUMARTIST . "+" . $ALBUM . "+" . $DATE . "+" . $GENRE . "+" . $MaxMTimeMusic; $Info = <<<EOT <?xml version="1.0" encoding="UTF-8"?> <Info> <Artist>{$ARTIST}</Artist> <AlbumArtist>{$ALBUMARTIST}</AlbumArtist> <Album>{$ALBUM}</Album> <Date>{$DATE}</Date> <Genre>{$GENRE}</Genre> <MusicTime>{$MaxMTimeMusic}</MusicTime> <Playlist>{$PLAYLIST}</Playlist> <NoTracks>{$cnt}</NoTracks> <Art>{$ART}</Art> <Art80>{$ART80}</Art80> <Art160>{$ART160}</Art160> </Info> EOT; $Playlist = Linn_Playlist($Tracks); } else { $Key = ""; $Info = ""; $Playlist = ""; } return $cnt > 0; }