Пример #1
0
function test()
{
    global $NL;
    $musicDB = new MusicDB();
    $musicDB->SetState("State1", "Value1");
    $musicDB->SetState("State2", "Value1");
    echo $musicDB->NumberOfAlbumsInMenuNo(0) . $NL;
    echo $musicDB->NumberOfAlbumsInMenuNo(1) . $NL;
    echo $musicDB->NumberOfAlbumsInMenuNo(2) . $NL;
    echo $musicDB->NumberOfAlbumsInMenuNo(3) . $NL;
    $musicDB->close();
}
Пример #2
0
function Main($DoLevel)
{
    global $NL;
    global $RootMenu;
    global $SubMenuType;
    global $TopDirectory;
    global $AppDir;
    global $DATABASE_FILENAME;
    $AppDir = "site/";
    if (!file_exists($AppDir . "folder")) {
        mkdir($AppDir . "folder");
    }
    if (!file_exists($AppDir . "sprites")) {
        mkdir($AppDir . "sprites");
    }
    $NumNewPlaylists = 0;
    //Create a didl file in each directory containing music
    if ($DoLevel > 3) {
        echo "Removing old .dpl files" . $NL;
        UnlinkDPL();
    }
    echo "Making a didl file in each directory..." . $NL;
    $NumNewPlaylists = MakePlaylists($TopDirectory);
    echo " - found {$NumNewPlaylists} new playlists" . $NL;
    unlink($DATABASE_FILENAME);
    $musicDB = new MusicDB();
    echo "Find all didl files and add to Menu tree..." . $NL;
    // Find all didl files and add it to the menus
    try {
        CreateAllGreyImgs($musicDB->MaxPreset());
        foreach ($TopDirectory as $Dir => $RootMenuNo) {
            $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($Dir));
            while ($it->valid()) {
                if ($it->isFile()) {
                    $ext = pathinfo($it->current(), PATHINFO_EXTENSION);
                    if ($ext == "xml") {
                        $didl = new DIDL_Album($it->getPathName(), $RootMenuNo);
                        $rowid = $musicDB->CheckURLExist($didl->URI());
                        if ($rowid === false) {
                            $rowid = Make_Album($didl, $musicDB);
                            Make_Tracks($didl, $musicDB);
                            //$didl->dump();
                        } else {
                            $didl->SetSequenceNo($rowid);
                        }
                        CollectFolderImgs($didl);
                        echo ".";
                    }
                }
                $it->next();
            }
        }
    } catch (Exception $e) {
        echo $e->getMessage();
    }
    copy("index.php", $AppDir . "index.php");
    copy("html_parts.php", $AppDir . "html_parts.php");
    copy("actions.js", $AppDir . "actions.js");
    copy("musik.css", $AppDir . "musik.css");
    copy("LinnDS-jukebox-daemon.php", $AppDir . "LinnDS-jukebox-daemon.php");
    copy("ServerState.php", $AppDir . "ServerState.php");
    copy("LPECClientSocket.php", $AppDir . "LPECClientSocket.php");
    copy("LinnDSClientSocket.php", $AppDir . "LinnDSClientSocket.php");
    copy("StringUtils.php", $AppDir . "StringUtils.php");
    copy("SocketServer.php", $AppDir . "SocketServer.php");
    copy("LinnDS-jukebox-daemon-old.php", $AppDir . "LinnDS-jukebox-daemon-old.php");
    copy("S98linn_lpec", $AppDir . "S98linn_lpec");
    copy("Transparent.gif", $AppDir . "Transparent.gif");
    copy("setup.php", $AppDir . "setup.php");
    copy("Send.php", $AppDir . "Send.php");
    copy("MusicDB.php", $AppDir . "MusicDB.php");
    copy("QueryAlbum.php", $AppDir . "QueryAlbum.php");
    copy("QueryAlbumList.php", $AppDir . "QueryAlbumList.php");
    copy("QueryAlphabetPresent.php", $AppDir . "QueryAlphabetPresent.php");
    copy("QueryDB.php", $AppDir . "QueryDB.php");
    copy("QueryPlayingNowDB.php", $AppDir . "QueryPlayingNowDB.php");
    echo "Making sprites and css file in " . $AppDir . $NL;
    Make_CSS($musicDB->MaxPreset(), $AppDir . "sprites/sprites.css", $AppDir . "sprites/sprites@2x.css");
    $musicDB->close();
    copy($DATABASE_FILENAME, $AppDir . $DATABASE_FILENAME);
    echo "Finished..." . $NL;
}
         $State['TrackBitRate'] = $E[TrackBitRate];
     }
     if (strpos($data, "TrackLossless ") !== false) {
         $State['TrackLossless'] = $E[TrackLossless];
     }
     $DataHandled = true;
 } elseif (strpos($data, "EVENT " . $SubscribeType['Ds/Volume']) !== false) {
     if (strpos($data, "Volume ") !== false) {
         $State['Volume'] = $E[Volume];
         $musicDB = new MusicDB();
         $musicDB->SetState("Volume", $E[Volume]);
         $musicDB->close();
     }
     if (strpos($data, "Mute ") !== false) {
         $State['Mute'] = $E[Mute];
         $musicDB = new MusicDB();
         $musicDB->SetState("Mute", $E[Mute]);
         $musicDB->close();
     }
     $DataHandled = true;
 } elseif (strpos($data, "EVENT " . $SubscribeType['Ds/Jukebox']) !== false) {
     if (strpos($data, "CurrentPreset ") !== false) {
         $State['CurrentPreset'] = $E[CurrentPreset];
     }
     if (strpos($data, "CurrentBookmark ") !== false) {
         $State['CurrentBookmark'] = $E[CurrentBookmark];
     }
     $DataHandled = true;
 } else {
     LogWrite("UNKNOWN : " . $data);
     $DataHandled = true;
 public function processMessage($message)
 {
     LogWrite("LPECClientSocket::processMessage - {$message}");
     $DataHandled = false;
     if ($DEBUG > 1) {
         LogWrite($message);
     }
     if (strpos($message, "ALIVE Ds") !== false) {
         $this->Send("SUBSCRIBE Ds/Product");
         $DataHandled = true;
     } elseif (strpos($message, "ALIVE") !== false) {
         LogWrite("ALIVE ignored : " . $message);
         $DataHandled = true;
     } elseif (strpos($message, "ERROR") !== false) {
         LogWrite("ERROR ignored : " . $message);
         $DataHandled = true;
     } elseif (strpos($message, "SUBSCRIBE") !== false) {
         // SUBSCRIBE are sent by Linn when a SUBSCRIBE finishes, thus
         // we send the possible next command (Send) after removing
         // previous command.
         // We record the Number to Subscribe action in the array to
         // help do less work with the events.
         $front = array_shift($this->Queue);
         if ($DEBUG > 1) {
             LogWrite("Command: " . $front . " -> " . $message);
         }
         $S1 = substr($front, 10);
         $S2 = substr($message, 10);
         $this->SubscribeType[$S1] = $S2;
         $this->Send("");
         $DataHandled = true;
     } elseif (strpos($message, "RESPONSE") !== false) {
         // RESPONSE are sent by Linn when an ACTION finishes, thus we
         // send the possible next command (Send) after removing
         // previous command.
         $front = array_shift($this->Queue);
         if ($DEBUG > 0) {
             LogWrite("Command: " . $front . " -> " . $message);
         }
         if (strpos($front, "ACTION Ds/Product 1 Source ") !== false) {
             //ACTION Ds/Product 1 Source \"(\d+)\"
             //RESPONSE \"([[:ascii:]]+?)\" \"([[:ascii:]]+?)\" \"([[:ascii:]]+?)\" \"([[:ascii:]]+?)\"
             $F = getParameters($front);
             $D = getParameters($message);
             //$State['Source_SystemName'][$F[0]] = $D[0];
             //$State['Source_Type'][$F[0]] = $D[1];
             //$State['Source_Name'][$F[0]] = $D[2];
             //$State['Source_Visible'][$F[0]] = $D[3];
             $this->getState()->setStateArray('SourceName', $D[2], $F[0]);
             if ($D[1] == "Playlist") {
                 // We have the Playlist service. subscribe...
                 $this->Send("SUBSCRIBE Ds/Playlist");
                 //$this->Send("SUBSCRIBE Ds/Jukebox");
             } elseif ($D[1] == "Radio") {
                 // We have the Radio service. subscribe...
                 //$this->Send("SUBSCRIBE Ds/Radio");
             }
         } elseif (strpos($front, "ACTION Ds/Playlist 1 Read ") !== false) {
             //ACTION Ds/Playlist 1 Read \"(\d+)\"
             //RESPONSE \"([[:ascii:]]+?)\" \"([[:ascii:]]+?)\"
             $F = getParameters($front);
             $D = getParameters($message);
             $this->getState()->setStateArray('PlaylistURLs', $F[0], $D[0]);
             $this->getState()->setStateArray('PlaylistXMLs', $F[0], $D[1]);
             $musicDB = new MusicDB();
             $musicDB->UpdateQueue($F[0], -1, -1, $D[0], $D[1]);
             $musicDB->close();
         } elseif (strpos($front, "ACTION Ds/Playlist 1 Insert ") !== false) {
             //ACTION Ds/Playlist 1 Insert \"(\d+)\" \"([[:ascii:]]+?)\" \"([[:ascii:]]+?)\"
             //RESPONSE \"([[:ascii:]]+?)\"
             $F = getParameters($front);
             $D = getParameters($message);
             $this->getState()->setState('NewId', $D[0]);
             $this->getState()->setStateArray('PlaylistURLs', $D[0], $F[1]);
             $this->getState()->setStateArray('PlaylistXMLs', $D[0], $F[2]);
             $musicDB = new MusicDB();
             $musicDB->UpdateQueue($D[0], -1, -1, $F[1], $F[2]);
             $musicDB->close();
         } elseif (strpos($front, "ACTION Ds/Playlist 1 IdArray") !== false) {
             //ACTION Ds/Playlist 1 IdArray
             //RESPONSE \"([[:ascii:]]+?)\" \"([[:ascii:]]+?)\"
             $F = getParameters($front);
             $D = getParameters($message);
             $this->getState()->setState('IdArray_Token', $D[0]);
             $this->getState()->setState('IdArray_base64', $D[1]);
             $this->getState()->setState('IdArray', unpack("N*", base64_decode($D[1])));
             $musicDB = new MusicDB();
             $this->CheckPlaylist($musicDB);
             $musicDB->close();
         }
         $this->Send("");
         $DataHandled = true;
     } elseif (strpos($message, "EVENT ") !== false) {
         // EVENTs are sent by Your linn - those that were subscribed
         // to. We think the below ones are interesting....
         $E = getEvent($message);
         if (strpos($message, "EVENT " . $this->SubscribeType['Ds/Product']) !== false) {
             if (strpos($message, "SourceIndex ") !== false) {
                 $this->getState()->setState('SourceIndex', $E[SourceIndex]);
             }
             if (strpos($message, "ProductModel ") !== false) {
                 $this->getState()->setState('ProductModel', $E[ProductModel]);
             }
             if (strpos($message, "ProductName ") !== false) {
                 $this->getState()->setState('ProductName', $E[ProductName]);
             }
             if (strpos($message, "ProductRoom ") !== false) {
                 $this->getState()->setState('ProductRoom', $E[ProductRoom]);
             }
             if (strpos($message, "ProductType ") !== false) {
                 $this->getState()->setState('ProductType', $E[ProductType]);
             }
             if (strpos($message, "Standby ") !== false) {
                 $this->getState()->setState('Standby', $E[Standby]);
                 $musicDB = new MusicDB();
                 $musicDB->SetState("Standby", $E[Standby]);
                 $musicDB->close();
             }
             if (strpos($message, "ProductUrl ") !== false) {
                 $this->getState()->setState('ProductUrl', $E[ProductUrl]);
             }
             if (strpos($message, "Attributes ") !== false) {
                 $this->getState()->setState('Attributes', $E[Attributes]);
                 if (strpos($E[Attributes], "Volume") !== false) {
                     $this->Send("SUBSCRIBE Ds/Volume");
                 }
                 if (strpos($E[Attributes], "Info") !== false) {
                     //$this->Send("SUBSCRIBE Ds/Info");
                 }
                 if (strpos($E[Attributes], "Time") !== false) {
                     //$this->Send("SUBSCRIBE Ds/Time");
                 }
             }
             if (strpos($message, "SourceCount ") !== false) {
                 for ($i = 0; $i < $E[SourceCount]; $i++) {
                     $this->Send("ACTION Ds/Product 1 Source \"" . $i . "\"");
                 }
             }
             $DataHandled = true;
         } elseif (strpos($message, "EVENT " . $this->SubscribeType['Ds/Playlist']) !== false) {
             if (strpos($message, "TransportState ") !== false) {
                 $this->getState()->setState('TransportState', $E[TransportState]);
                 $musicDB = new MusicDB();
                 $musicDB->SetState("TransportState", $E[TransportState]);
                 $musicDB->close();
             }
             if (strpos($message, "Id ") !== false) {
                 $this->getState()->setState('Id', $E[Id]);
                 $musicDB = new MusicDB();
                 $musicDB->SetState("LinnId", $E[Id]);
                 $musicDB->close();
             }
             if (strpos($message, "IdArray ") !== false) {
                 $this->getState()->setState('IdArray_base64', $E[IdArray]);
                 $this->getState()->setState('IdArray', unpack("N*", base64_decode($E[IdArray])));
                 $musicDB = new MusicDB();
                 $this->CheckPlaylist($musicDB);
                 $musicDB->close();
             }
             if (strpos($message, "Shuffle ") !== false) {
                 $this->getState()->setState('Shuffle', $E[Shuffle]);
             }
             if (strpos($message, "Repeat ") !== false) {
                 $this->getState()->setState('Repeat', $E[Repeat]);
             }
             if (strpos($message, "TrackDuration ") !== false) {
                 $this->getState()->setState('TrackDuration', $E[TrackDuration]);
             }
             if (strpos($message, "TrackCodecName ") !== false) {
                 $this->getState()->setState('TrackCodecName', $E[TrackCodecName]);
             }
             if (strpos($message, "TrackSampleRate ") !== false) {
                 $this->getState()->setState('TrackSampleRate', $E[TrackSampleRate]);
             }
             if (strpos($message, "TrackBitRate ") !== false) {
                 $this->getState()->setState('TrackBitRate', $E[TrackBitRate]);
             }
             if (strpos($message, "TrackLossless ") !== false) {
                 $this->getState()->setState('TrackLossless', $E[TrackLossless]);
             }
             $DataHandled = true;
         } elseif (strpos($message, "EVENT " . $this->SubscribeType['Ds/Volume']) !== false) {
             if (strpos($message, "Volume ") !== false) {
                 LogWrite("Event Volume");
                 $this->getState()->setState('Volume', $E[Volume]);
                 $musicDB = new MusicDB();
                 $musicDB->SetState("Volume", $E[Volume]);
                 $musicDB->close();
             }
             if (strpos($message, "Mute ") !== false) {
                 $this->getState()->setState('Mute', $E[Mute]);
                 $musicDB = new MusicDB();
                 $musicDB->SetState("Mute", $E[Mute]);
                 $musicDB->close();
             }
             $DataHandled = true;
         } elseif (strpos($message, "EVENT " . $this->SubscribeType['Ds/Jukebox']) !== false) {
             if (strpos($message, "CurrentPreset ") !== false) {
                 $this->getState()->setState('CurrentPreset', $E[CurrentPreset]);
             }
             if (strpos($message, "CurrentBookmark ") !== false) {
                 $this->getState()->setState('CurrentBookmark', $E[CurrentBookmark]);
             }
             $DataHandled = true;
         } else {
             LogWrite("UNKNOWN : " . $message);
             $DataHandled = true;
         }
     }
     return $DataHandled;
 }