public function executeAction() { $request = $this->getRequest(); //X_VlcShares_Plugins::broker()->gen_preProviderSelection($this); /* $provider = $request->getParam('p', false); if ( $provider === false || !X_VlcShares_Plugins::broker()->isRegistered($provider) ) { throw new Exception("Invalid provider"); } $location = X_Env::decode($request->getParam('l', '')); */ $pid = $request->getParam('pid', false); $a = $request->getParam('a', false); $engineId = X_Streamer::i()->getStreamingEngineId(); $engine = X_VlcShares_Plugins::helpers()->streamer()->get($engineId); X_VlcShares_Plugins::broker()->preExecute($engine, $pid, $a, $this); X_VlcShares_Plugins::broker()->execute($engine, $pid, $a, $this); X_VlcShares_Plugins::broker()->postExecute($engine, $pid, $a, $this); $pageItems = new X_Page_ItemList_PItem(); $done = new X_Page_Item_PItem('core-opdone', X_Env::_('controls_done')); $done->setCustom('vlc_still_alive', $this->vlc->isRunning())->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('controller' => 'controls', 'action' => 'control', 'pid' => null, 'a' => null, 'param' => null), 'default', false); $pageItems->append($done); // links on top $pageItems->merge(X_VlcShares_Plugins::broker()->preGetExecuteItems($pid, $a, $this)); // add separator between play items and options items $separator = new X_Page_Item_PItem('core-separator', X_Env::_('_____options_separator_____')); $separator->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('controller' => 'controls', 'action' => 'control', 'pid' => null, 'a' => null, 'param' => null), 'default', false); $pageItems->append($separator); // normal links $pageItems->merge(X_VlcShares_Plugins::broker()->getExecuteItems($pid, $a, $this)); // bottom links $pageItems->merge(X_VlcShares_Plugins::broker()->postGetExecuteItems($pid, $a, $this)); // trigger for page creation X_VlcShares_Plugins::broker()->gen_afterPageBuild($pageItems, $this); }
/** * Add button -watch youtube stream directly- * * @param string $provider * @param string $location * @param Zend_Controller_Action $controller */ public function preGetModeItems($provider, $location, Zend_Controller_Action $controller) { if ($provider != $this->getId()) { return; } X_Debug::i("Plugin triggered"); // i have to remove default sub provider // and install the newer one in getModeItems X_VlcShares_Plugins::broker()->unregisterPluginClass('X_VlcShares_Plugins_FileSubs'); $url = $this->resolveLocation($location); if ($url) { // i have to check for rtsp videos, wiimc can't handle them if (X_Env::startWith($url, 'rtsp') && $this->helpers()->devices()->isWiimc()) { return; } $link = new X_Page_Item_PItem('core-directwatch', X_Env::_('p_youtube_watchdirectly')); $link->setIcon('/images/icons/play.png')->setType(X_Page_Item_PItem::TYPE_PLAYABLE)->setLink($url); // add tag wiimcplus_subtitle for subtitle in direct watching if ($this->config('closedcaption.enabled', true)) { /* @var $request Zend_Controller_Request_Http */ $request = $controller->getRequest(); $sub = false; $lc = $request->getParam($this->getId() . ':sub', false); if ($lc !== false) { @(list(, , , $videoId) = explode('/', $location)); $sub = array('controller' => 'youtube', 'action' => 'convert', 'v' => $videoId, 'l' => $lc, 'f' => 'file.srt'); } /* @var $urlHelper Zend_Controller_Action_Helper_Url */ $urlHelper = $controller->getHelper('url'); if ($sub !== false) { $link->setCustom('subtitle', X_Env::completeUrl($urlHelper->url($sub, 'default', true))); X_Debug::i("CC-XML to SRT Url: " . X_Env::completeUrl($urlHelper->url($sub, 'default', true))); } } @(list(, , , $videoId) = explode('/', $location)); $link2 = new X_Page_Item_PItem('core-directwatch', "Watch throught WIIMC"); $link2->setIcon('/images/icons/play.png')->setType(X_Page_Item_PItem::TYPE_PLAYABLE)->setLink("http://www.youtube.com/watch?v={$videoId}"); return new X_Page_ItemList_PItem(array($link, $link2)); } else { // if there is no link, i have to remove start-vlc button // and replace it with a Warning button X_Debug::i('Setting priority to filterModeItems'); $this->setPriority('filterModeItems', 99); $link = new X_Page_Item_PItem('youtube-warning', X_Env::_('p_youtube_invalidyoutube')); $link->setIcon('/images/msg_error.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('controller' => 'browse', 'action' => 'share', 'p' => $this->getId(), 'l' => X_Env::encode($this->getParentLocation($location))), 'default', true); return new X_Page_ItemList_PItem(array($link)); } }
private function _fillPlaylist(X_Page_ItemList_PItem $items, $decoded, $lStack) { X_Debug::i("Decoded: " . print_r($decoded, true)); // The format of $decoded (only notable parts): // { // ok: true|false // msg: $msg ; Setted only if ok = false // folderId: $thisFolder // folders: [ // { // id: $folderID // name: $folderName // }, ... // ] // objects: [ // { // id: $objectID // name: $objectName // link: http://...?...&video=urlencoded(URL)&... // }, // { // id: $objectID // name: $objectName // link: http://...?...&host=megavideo&video=urlencoded(MEGAVIDEOURL)&... // }, // ] // ... // } foreach ($decoded->folders as $folder) { $_stack = $lStack; $_stack[] = $folder->id; $item = new X_Page_Item_PItem("opfitalia-folder-{$folder->id}", urldecode($folder->name)); $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setGenerator(__CLASS__)->setCustom(__CLASS__ . ':location', implode(':', $_stack))->setLink(array('l' => X_Env::encode(implode(':', $_stack))), 'default', false); $items->append($item); } foreach ($decoded->objects as $object) { $item = new X_Page_Item_PItem("opfitalia-video-{$object->id}", urldecode($object->name)); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setGenerator(__CLASS__); // time to decode the link arg // file: index.php?page=show_streaming&video=http:\/\/www.dbforever.net\/strm\/onepiece\/one_piece_459.mp4&width=704&height=430 // megavideo: index.php?page=show_streaming&host=megavideo&video=http:\/\/www.megavideo.com\/v\/GIV2R76V038221ac298ceb332a9cad75288c318b&width=640&height=480 $link = explode('&', $object->link); $type = 'file'; $href = ''; foreach ($link as $sublink) { list($arg, $value) = @explode('=', $sublink, 2); if ($arg == 'host') { if ($value == 'megavideo') { $type = 'megavideo'; } } if ($arg == 'video') { $href = str_replace('\\/', '/', urldecode($value)); } } if ($type == 'megavideo') { // i gave to split the /v/ param only $splitted = explode('/v/', $href, 2); if (count($splitted) == 2) { $href = $splitted[1]; } else { // try to decode it // as ?v= preg_match('#\\?v=(.+?)$#', $href, $id); if (count($id) >= 2) { $href = $id[1]; } else { // if even this fail // i have to skip thi entry continue; } } $item->setLabel($item->getLabel() . " [Megavideo]"); } $item->setCustom(__CLASS__ . ':location', implode(':', $lStack) . "/{$type}/{$href}")->setLink(array('action' => 'mode', 'l' => X_Env::encode(implode(':', $lStack) . "/{$type}/{$href}")), 'default', false); $items->append($item); } }