Exemplo n.º 1
0
 private function retrieveMediaFiles($id, $type)
 {
     $files = array();
     if ($type === "audioclip") {
         $file = CcFilesQuery::create()->findPK($id, $this->con);
         if (is_null($file) || !$file->getDbFileExists()) {
             throw new Exception("A selected File does not exist!");
         } else {
             $data = $this->fileInfo;
             $data["id"] = $id;
             $data["cliplength"] = $file->getDbLength();
             $data["cueout"] = $file->getDbLength();
             $defaultFade = Application_Model_Preference::GetDefaultFade();
             if (isset($defaultFade)) {
                 //fade is in format SS.uuuuuu
                 $data["fadein"] = $defaultFade;
                 $data["fadeout"] = $defaultFade;
             }
             $files[] = $data;
         }
     } elseif ($type === "playlist") {
         $pl = new Application_Model_Playlist($id);
         $contents = $pl->getContents();
         foreach ($contents as $plItem) {
             if ($plItem['type'] == 0) {
                 $data["id"] = $plItem['item_id'];
                 $data["cliplength"] = $plItem['length'];
                 $data["cuein"] = $plItem['cuein'];
                 $data["cueout"] = $plItem['cueout'];
                 $data["fadein"] = $plItem['fadein'];
                 $data["fadeout"] = $plItem['fadeout'];
                 $data["type"] = 0;
                 $files[] = $data;
             } elseif ($plItem['type'] == 1) {
                 $data["id"] = $plItem['item_id'];
                 $data["cliplength"] = $plItem['length'];
                 $data["cuein"] = $plItem['cuein'];
                 $data["cueout"] = $plItem['cueout'];
                 $data["fadein"] = "00.500000";
                 //$plItem['fadein'];
                 $data["fadeout"] = "00.500000";
                 //$plItem['fadeout'];
                 $data["type"] = 1;
                 $files[] = $data;
             } elseif ($plItem['type'] == 2) {
                 // if it's a block
                 $bl = new Application_Model_Block($plItem['item_id']);
                 if ($bl->isStatic()) {
                     foreach ($bl->getContents() as $track) {
                         $data["id"] = $track['item_id'];
                         $data["cliplength"] = $track['length'];
                         $data["cuein"] = $track['cuein'];
                         $data["cueout"] = $track['cueout'];
                         $data["fadein"] = $track['fadein'];
                         $data["fadeout"] = $track['fadeout'];
                         $data["type"] = 0;
                         $files[] = $data;
                     }
                 } else {
                     $dynamicFiles = $bl->getListOfFilesUnderLimit();
                     foreach ($dynamicFiles as $fileId => $f) {
                         $file = CcFilesQuery::create()->findPk($fileId);
                         if (isset($file) && $file->getDbFileExists()) {
                             $data["id"] = $file->getDbId();
                             $data["cliplength"] = $file->getDbLength();
                             $data["cuein"] = "00:00:00";
                             $data["cueout"] = $file->getDbLength();
                             $defaultFade = Application_Model_Preference::GetDefaultFade();
                             if (isset($defaultFade)) {
                                 //fade is in format SS.uuuuuu
                                 $data["fadein"] = $defaultFade;
                                 $data["fadeout"] = $defaultFade;
                             }
                             $data["type"] = 0;
                             $files[] = $data;
                         }
                     }
                 }
             }
         }
     } elseif ($type == "stream") {
         //need to return
         $stream = CcWebstreamQuery::create()->findPK($id, $this->con);
         if (is_null($stream)) {
             throw new Exception("A selected File does not exist!");
         } else {
             $data = $this->fileInfo;
             $data["id"] = $id;
             $data["cliplength"] = $stream->getDbLength();
             $data["cueout"] = $stream->getDbLength();
             $data["type"] = 1;
             $defaultFade = Application_Model_Preference::GetDefaultFade();
             if (isset($defaultFade)) {
                 //fade is in format SS.uuuuuu
                 $data["fadein"] = $defaultFade;
                 $data["fadeout"] = $defaultFade;
             }
             $files[] = $data;
         }
     } elseif ($type == "block") {
         $bl = new Application_Model_Block($id);
         if ($bl->isStatic()) {
             foreach ($bl->getContents() as $track) {
                 $data["id"] = $track['item_id'];
                 $data["cliplength"] = $track['length'];
                 $data["cuein"] = $track['cuein'];
                 $data["cueout"] = $track['cueout'];
                 $data["fadein"] = $track['fadein'];
                 $data["fadeout"] = $track['fadeout'];
                 $data["type"] = 0;
                 $files[] = $data;
             }
         } else {
             $dynamicFiles = $bl->getListOfFilesUnderLimit();
             foreach ($dynamicFiles as $fileId => $f) {
                 $file = CcFilesQuery::create()->findPk($fileId);
                 if (isset($file) && $file->getDbFileExists()) {
                     $data["id"] = $file->getDbId();
                     $data["cliplength"] = $file->getDbLength();
                     $data["cuein"] = "00:00:00";
                     $data["cueout"] = $file->getDbLength();
                     $defaultFade = Application_Model_Preference::GetDefaultFade();
                     if (isset($defaultFade)) {
                         //fade is in format SS.uuuuuu
                         $data["fadein"] = $defaultFade;
                         $data["fadeout"] = $defaultFade;
                     }
                     $data["type"] = 0;
                     $files[] = $data;
                 }
             }
         }
     }
     return $files;
 }
 /**
  *Function will load and return the contents of the requested playlist.
  */
 public function getPlaylistAction()
 {
     // disable the view and the layout
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $playlistID = $this->_getParam('playlistID');
     if (!isset($playlistID)) {
         return;
     }
     $pl = new Application_Model_Playlist($playlistID);
     $result = array();
     foreach ($pl->getContents(true) as $ele) {
         if ($ele['type'] == 2) {
             // if element is a block expand and add
             $bl = new Application_Model_Block($ele['item_id']);
             if ($bl->isStatic()) {
                 foreach ($bl->getContents(true) as $track) {
                     $result[] = $this->createElementMap($track);
                 }
             }
         } else {
             $result[] = $this->createElementMap($ele);
         }
     }
     $this->_helper->json($result);
 }
 public function getBlockInfoAction()
 {
     $request = $this->getRequest();
     $params = $request->getPost();
     $bl = new Application_Model_Block($params['id']);
     if ($bl->isStatic()) {
         $out = $bl->getContents();
         $out['isStatic'] = true;
     } else {
         $out = $bl->getCriteria();
         $out['isStatic'] = false;
     }
     $this->_helper->json->sendJson($out);
 }
Exemplo n.º 4
0
 public function getFileMetadataAction()
 {
     $id = $this->_getParam('id');
     $type = $this->_getParam('type');
     try {
         if ($type == "audioclip") {
             $file = Application_Model_StoredFile::Recall($id);
             $this->view->type = $type;
             $md = $file->getMetadata();
             foreach ($md as $key => $value) {
                 if ($key == 'MDATA_KEY_DIRECTORY') {
                     $musicDir = Application_Model_MusicDir::getDirByPK($value);
                     $md['MDATA_KEY_FILEPATH'] = Application_Common_OsPath::join($musicDir->getDirectory(), $md['MDATA_KEY_FILEPATH']);
                 }
             }
             $formatter = new SamplerateFormatter($md["MDATA_KEY_SAMPLERATE"]);
             $md["MDATA_KEY_SAMPLERATE"] = $formatter->format();
             $formatter = new BitrateFormatter($md["MDATA_KEY_BITRATE"]);
             $md["MDATA_KEY_BITRATE"] = $formatter->format();
             $formatter = new LengthFormatter($md["MDATA_KEY_DURATION"]);
             $md["MDATA_KEY_DURATION"] = $formatter->format();
             $this->view->md = $md;
         } elseif ($type == "playlist") {
             $file = new Application_Model_Playlist($id);
             $this->view->type = $type;
             $md = $file->getAllPLMetaData();
             $formatter = new LengthFormatter($md["dcterms:extent"]);
             $md["dcterms:extent"] = $formatter->format();
             $this->view->md = $md;
             $this->view->contents = $file->getContents();
         } elseif ($type == "block") {
             $block = new Application_Model_Block($id);
             $this->view->type = $type;
             $md = $block->getAllPLMetaData();
             $formatter = new LengthFormatter($md["dcterms:extent"]);
             $md["dcterms:extent"] = $formatter->format();
             $this->view->md = $md;
             if ($block->isStatic()) {
                 $this->view->blType = 'Static';
                 $this->view->contents = $block->getContents();
             } else {
                 $this->view->blType = 'Dynamic';
                 $this->view->contents = $block->getCriteria();
             }
             $this->view->block = $block;
         } elseif ($type == "stream") {
             $webstream = CcWebstreamQuery::create()->findPK($id);
             $ws = new Application_Model_Webstream($webstream);
             $md = $ws->getMetadata();
             $this->view->md = $md;
             $this->view->type = $type;
         }
     } catch (Exception $e) {
         Logging::info($e->getMessage());
     }
 }