Example #1
0
 static function registerVlcLocation(X_VlcShares_Plugins_ResolverInterface $plugin, X_Vlc $vlc, $location)
 {
     $location = $plugin->resolveLocation($location);
     if ($location !== null) {
         $vlc->registerArg('source', "\"{$location}\"");
     } else {
         X_Debug::e("No source o_O");
     }
 }
 /**
  * This hook can be used check vlc status just before
  * spawn is called
  * 
  * @param X_Vlc $vlc vlc wrapper object
  * @param string $provider id of the plugin that should handle request
  * @param string $location to stream
  * @param Zend_Controller_Action $controller the controller who handle the request
  */
 public function preSpawnVlc(X_Vlc $vlc, $provider, $location, Zend_Controller_Action $controller)
 {
     // TODO port to newer api when ready
     // when newer X_Vlc's api will be ready
     // i will need change this to
     // $source = $vlc->getSource();
     // and double quote removal will be automatic
     $source = $vlc->getArg('source');
     $provider = X_VlcShares_Plugins::broker()->getPlugins($provider);
     //if ( X_Env::isWindows() && !X_Env::startWith($source, 'http://') && !X_Env::startWith($source, 'https://') ) {
     if (X_Env::isWindows() && is_a($provider, 'X_VlcShares_Plugins_FileSystem')) {
         // with newer api this will be useless
         $source = realpath(trim($source, '"'));
         // when newer X_Vlc's api will be ready
         // i will need change this to
         // $vlc->setSource($source);
         // and double quotation will be automatic
         $vlc->registerArg('source', "\"{$source}\"");
     }
 }
Example #3
0
 public function __construct($options = array())
 {
     if (!$options instanceof Zend_Config) {
         if (!is_array($options)) {
             $options = array();
         }
         $options = new Zend_Config($options);
     }
     // store the options for lazyinit
     $this->options = $options;
     // store the instance for lastInstance
     self::$instance = $this;
 }
 /**
  * This hook can be used to add low priority args in vlc stack
  * 
  * @param X_Vlc $vlc vlc wrapper object
  * @param string $provider id of the plugin that should handle request
  * @param string $location to stream
  * @param Zend_Controller_Action $controller the controller who handle the request
  */
 public function preRegisterVlcArgs(X_Vlc $vlc, $provider, $location, Zend_Controller_Action $controller)
 {
     // this plugin inject params only if this is the provider
     if ($provider != $this->getId()) {
         return;
     }
     // i need to register source as first, because subtitles plugin use source
     // for create subfile
     X_Debug::i('Plugin triggered');
     $location = $this->resolveLocation($location);
     if ($location !== null) {
         // TODO adapt to newer api when ready
         $vlc->registerArg('source', "\"{$location}\"");
     } else {
         X_Debug::e("No source o_O");
     }
 }
 public function shutdownAction()
 {
     X_Env::debug(__METHOD__);
     $this->vlc->forceKill();
     if (strpos($_SERVER['HTTP_USER_AGENT'], 'WiiMC') !== false) {
         // wiimc 1.0.5 e inferiori nn accetta redirect
         $this->_forward('index', 'index');
     } else {
         $isAjax = $this->getRequest()->getParam('ajax', false);
         if ($isAjax) {
             $this->_forward('status');
         } else {
             $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
             $redirector->gotoSimpleAndExit('control');
         }
     }
 }
 /**
  * Retrieve core statistics
  * @param Zend_Controller_Action $this
  * @return X_Page_ItemList_Statistic
  */
 public function getIndexStatistics(Zend_Controller_Action $controller)
 {
     $plugins = count(X_VlcShares_Plugins::broker()->getPlugins());
     $helpers = count(X_VlcShares_Plugins::helpers()->getHelpers());
     $pluginsList = '<div class="scrollable" style="max-height: 75px;"><ol>';
     foreach (X_VlcShares_Plugins::broker()->getPlugins() as $pluginName => $pluginObj) {
         $explodedClass = explode('_', get_class($pluginObj));
         $formattedPluginClass = array_pop($explodedClass);
         $pluginsList .= "<li style=\"font-weight: normal;\">{$formattedPluginClass}</li>\n";
     }
     $pluginsList .= "</ol></div>";
     $helpersList = '<div class="scrollable" style="max-height: 75px;"><ol>';
     foreach (X_VlcShares_Plugins::helpers()->getHelpers() as $pluginName => $pluginObj) {
         $explodedClass = explode('_', get_class($pluginObj));
         $formattedPluginClass = array_pop($explodedClass);
         $helpersList .= "<li style=\"font-weight: normal;\">{$formattedPluginClass}</li>\n";
     }
     $helpersList .= "</ol></div>";
     $vlc = X_Vlc::getLastInstance()->isRunning() ? X_Env::_('p_corestats_vlcrunning_yes') : X_Env::_('p_corestats_vlcrunning_no');
     $stat = new X_Page_Item_Statistic($this->getId(), X_Env::_('p_corestats_statstitle'));
     $stat->setTitle(X_Env::_('p_corestats_statstitle'))->appendStat(X_Env::_('p_corestats_vlcrunning') . ": {$vlc}")->appendStat(X_Env::_('p_corestats_pluginnumber') . ": {$plugins}")->appendStat(X_Env::_('p_corestats_helpernumber') . ": {$helpers}")->appendStat(X_Env::_('p_corestats_pluginslist') . ": {$pluginsList}")->appendStat(X_Env::_('p_corestats_helperlist') . ": {$helpersList}");
     return new X_Page_ItemList_Statistic(array($stat));
 }
 /**
  * This hook can be used to add normal priority args in vlc stack
  * 
  * @param X_Vlc $vlc vlc wrapper object
  * @param string $provider id of the plugin that should handle request
  * @param string $location to stream
  * @param Zend_Controller_Action $controller the controller who handle the request
  */
 public function registerVlcArgs(X_Vlc $vlc, $provider, $location, Zend_Controller_Action $controller)
 {
     X_Debug::i('Plugin triggered');
     $profileId = $controller->getRequest()->getParam($this->getId(), false);
     if ($profileId !== false) {
         $profile = new Application_Model_Profile();
         Application_Model_ProfilesMapper::i()->find($profileId, $profile);
     } else {
         // if no params is provided, i will try to
         // get the best profile for this condition
         $profile = $this->getBest($location, $this->helpers()->devices()->getDeviceType(), $provider);
     }
     if ($profile->getArg() !== null) {
         $vlc->registerArg('profile', $profile->getArg());
         if ($this->config('store.session', true)) {
             // store the link in session for future use
             try {
                 /* @var $cache X_VlcShares_Plugins_Helper_Cache */
                 $cache = $this->helpers()->helper('cache');
                 $cache->storeItem('profile::lastvlclink', $profile->getLink(), 240);
             } catch (Exception $e) {
                 // nothing to store or no place to store to
             }
         }
     } else {
         X_Debug::e("No profile arg for vlc");
     }
 }
 public function streamAction()
 {
     $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', ''));
     $providerObj = X_VlcShares_Plugins::broker()->getPlugins($provider);
     // if provider is a resolver, i can use new streamer api
     if (X_VlcShares_Plugins::helpers()->streamer()->isEnabled() && $providerObj instanceof X_VlcShares_Plugins_ResolverInterface) {
         $url = $providerObj->resolveLocation($location);
         X_Debug::i("Resolved location: {{$url}}");
         // check if url is valid (resolver give null or false on error)
         if (!$url) {
             X_Debug::e("Invalid location: {$location}");
             throw new Exception("Stream location is invalid: {$url}");
         }
         $engine = X_VlcShares_Plugins::helpers()->streamer()->find($url);
         X_Debug::i("Streamer engine found: {{$engine->getId()}}");
         // automatically set the url as source param in the engine
         $engine->setSource($url);
         // NEW APIS
         // each arg is stored as in a LIFO stack. If i put top priority as first,
         // low priority args could override it. So i use an inverse priority insertion
         // register low priority args
         X_VlcShares_Plugins::broker()->preRegisterStreamerArgs($engine, $url, $provider, $location, $this);
         // register normal priority args
         X_VlcShares_Plugins::broker()->registerStreamerArgs($engine, $url, $provider, $location, $this);
         // register top priority args
         X_VlcShares_Plugins::broker()->postRegisterStreamerArgs($engine, $url, $provider, $location, $this);
         X_VlcShares_Plugins::broker()->preStartStreamer($engine, $url, $provider, $location, $this);
         $results = X_VlcShares_Plugins::broker()->canStartStreamer($engine, $url, $provider, $location, $this);
         $started = false;
         if (is_null($results) || !in_array(false, $results)) {
             X_Debug::i("Starting streamer {{$engine->getId()}}: {$engine}");
             $started = true;
             X_Streamer::i()->start($engine);
         } else {
             $pluginId = array_search(false, $results, true);
             X_Debug::f("Plugin {{$pluginId}} prevented streamer from starting...");
             //throw new Exception("Plugin {{$pluginId}} prevented streamer from starting");
         }
         X_VlcShares_Plugins::broker()->postStartStreamer($started, $engine, $url, $provider, $location, $this);
     } else {
         // otherwise i'm forced to fallback to old api
         //{{{ THIS CODE BLOCK WILL IS DEPRECATED AND WILL BE REMOVED IN 0.5.6 or 0.6
         //TODO remove in 0.5.6 or 0.6
         // each arg is stored as in a LIFO stack. If i put top priority as first,
         // low priority args could override it. So i use an inverse priority insertion
         // register low priority args
         X_VlcShares_Plugins::broker()->preRegisterVlcArgs($this->vlc, $provider, $location, $this);
         // register normal priority args
         X_VlcShares_Plugins::broker()->registerVlcArgs($this->vlc, $provider, $location, $this);
         // register top priority args
         X_VlcShares_Plugins::broker()->postRegisterVlcArgs($this->vlc, $provider, $location, $this);
         X_VlcShares_Plugins::broker()->preSpawnVlc($this->vlc, $provider, $location, $this);
         $this->vlc->spawn();
         X_VlcShares_Plugins::broker()->postSpawnVlc($this->vlc, $provider, $location, $this);
         try {
             $engine = X_VlcShares_Plugins::helpers()->streamer()->get('vlc');
         } catch (Exception $e) {
             X_Debug::w('No vlc streamer available');
             $engine = new X_Streamer_Engine_Vlc($this->vlc);
         }
         $url = $this->vlc->getArg('source');
         //}}}
     }
     $pageItems = new X_Page_ItemList_PItem();
     // i can't add here the go to play button
     // because i don't know the output type
     // i need to leave this to the plugins, too
     // i hope that an output manager plugin
     // will be always enabled
     // top links
     $pageItems->merge(X_VlcShares_Plugins::broker()->preGetStreamItems($engine, $url, $provider, $location, $this));
     // normal links
     $pageItems->merge(X_VlcShares_Plugins::broker()->getStreamItems($engine, $url, $provider, $location, $this));
     // bottom links
     $pageItems->merge(X_VlcShares_Plugins::broker()->postGetStreamItems($engine, $url, $provider, $location, $this));
     // trigger for page creation
     X_VlcShares_Plugins::broker()->gen_afterPageBuild($pageItems, $this);
 }
 /**
  * This hook can be used to add low priority args in vlc stack
  * 
  * @param X_Vlc $vlc vlc wrapper object
  * @param string $provider id of the plugin that should handle request
  * @param string $location to stream
  * @param Zend_Controller_Action $controller the controller who handle the request
  */
 public function preRegisterVlcArgs(X_Vlc $vlc, $provider, $location, Zend_Controller_Action $controller)
 {
     // this plugin inject params only if this is the provider
     if ($provider != $this->getId()) {
         return;
     }
     // i need to register source as first, because subtitles plugin use source
     // for create subfile
     X_Debug::i('Plugin triggered');
     $dLocation = $this->resolveLocation($location);
     if ($location !== null) {
         // TODO adapt to newer api when ready
         $vlc->registerArg('source', "\"{$dLocation}\"");
     } else {
         X_Debug::e("No source o_O");
         return;
     }
     // Now, it's time to check for sub parameter
     $request = $controller->getRequest();
     $sub = $request->getParam($this->getId() . ':sub', false);
     if ($sub !== false) {
         $sub = X_Env::decode($sub);
         /* @var $helper X_VlcShares_Plugins_Helper_Youtube */
         $helper = $this->helpers('youtube');
         list(, , , $videoId) = explode('/', $location);
         $sub = $helper->getSubtitleNOAPI($videoId, $sub);
         $urlHelper = $controller->getHelper('url');
         $subFile = X_Env::completeUrl($urlHelper->url($sub['srt_url'], 'default', true));
         $vlc->registerArg('subtitles', "--sub-file=\"{$subFile}\"");
     }
 }
 /**
  * This hook can be used to add normal priority args in vlc stack
  * 
  * @param X_Vlc $vlc vlc wrapper object
  * @param string $provider id of the plugin that should handle request
  * @param string $location to stream
  * @param Zend_Controller_Action $controller the controller who handle the request
  */
 public function registerVlcArgs(X_Vlc $vlc, $provider, $location, Zend_Controller_Action $controller)
 {
     X_Debug::i('Plugin triggered');
     $subParam = $controller->getRequest()->getParam($this->getId(), false);
     if ($subParam !== false) {
         $subParam = X_Env::decode($subParam);
         list($type, $sub) = explode(':', $subParam, 2);
         if ($type == self::FILE) {
             $source = trim($vlc->getArg('source'), '"');
             $filename = pathinfo($source, PATHINFO_FILENAME);
             // only the name of file, without ext
             $dirname = pathinfo($source, PATHINFO_DIRNAME);
             $subFile = $dirname . '/' . $filename . '.' . ltrim($sub, '.');
             $subFile = realpath($subFile);
             X_Debug::i("Alternative audio file selected: {$subFile}");
             $vlc->registerArg('audio', "--input-slave=\"{$subFile}\"");
         } elseif ($type == self::STREAM) {
             $sub = (int) $sub;
             X_Debug::i("Alternative audio track selected: {$sub}");
             $vlc->registerArg('audio', "--audio-track=\"{$sub}\"");
         }
     }
 }
 private function _action_pause(X_Vlc $vlc, $param)
 {
     $vlc->pause();
 }
 public function gen_afterPageBuild(X_Page_ItemList_PItem $list, Zend_Controller_Action $controller)
 {
     // force Rendering win over everythings
     /*if ( !$this->_forceRendering ) {
     			if ( !((bool) $this->config('forced.enabled', false)) && !$this->helpers()->devices()->isWiimc() ) return;
     		} 
     		*/
     // new renderer interface
     if (!$this->isDefaultRenderer()) {
         return;
     }
     X_Debug::i("Plugin triggered");
     $request = $controller->getRequest();
     $enhanced = $this->helpers()->devices()->isWiimcEnhanced() && $this->config('support.enhanced', true);
     $plx = new X_Plx(X_Env::_('p_wiimcplxrenderer_plxtitle_' . $request->getControllerName() . '_' . $request->getActionName()), X_Env::_('p_wiimcplxrenderer_plxdescription_' . $request->getControllerName() . '_' . $request->getActionName()));
     // wiimc plus custom tags
     if ($enhanced) {
         $plx->setWiimcplus_generator_name('vlc-shares');
         // uses the __call api
         $plx->setWiimcplus_generator_version(X_VlcShares::VERSION_CLEAN);
         // uses the __call api
         if ($request->getControllerName() == 'index' && $request->getActionName() == 'collections') {
             $plx->setWiimcplus_assert_mainmenu('true');
             // uses the __call api
         }
         // show the current time as custom playlist header tag if the page is controls/control or browse/stream
         if ($request->getControllerName() == 'controls' && $request->getActionName() == 'control' || $request->getControllerName() == 'browse' && $request->getActionName() == 'stream') {
             $vlc = X_Vlc::getLastInstance();
             if ($vlc) {
                 // check to be sure that vlc is running right now
                 $currentTime = X_Env::formatTime($vlc->getCurrentTime());
                 $totalTime = X_Env::formatTime($vlc->getTotalTime());
                 $plx->setWiimcplus_current_time("{$currentTime}/{$totalTime}");
                 // uses the __call api
             }
         } elseif ($request->getControllerName() == 'browse' && $request->getActionName() == 'selection') {
             $plx->setWiimcplus_assert_nohistory('true');
             // uses the __call api
         }
     }
     foreach ($list->getItems() as $i => $item) {
         /* @var $item X_Page_Item_PItem */
         $plxItemName = ($item->isHighlight() ? '-) ' : '') . $item->getLabel();
         $plxItemWiimcplusIcon = null;
         switch ($item->getType()) {
             case X_Page_Item_PItem::TYPE_CONTAINER:
                 $plxItemType = X_Plx_Item::TYPE_PLAYLIST;
                 $plxItemWiimcplusIcon = 'folder';
                 break;
             case X_Page_Item_PItem::TYPE_ELEMENT:
                 $plxItemType = X_Plx_Item::TYPE_PLAYLIST;
                 if ($request->getControllerName() == 'browse' && $request->getActionName() == 'share') {
                     $plxItemWiimcplusIcon = 'file';
                 }
                 break;
             case X_Page_Item_PItem::TYPE_REQUEST:
                 $plxItemType = X_Plx_Item::TYPE_SEARCH;
                 break;
             case X_Page_Item_PItem::TYPE_PLAYABLE:
                 $plxItemType = X_Plx_Item::TYPE_VIDEO;
                 break;
             default:
                 $plxItemType = $item->getType();
         }
         /* @var $urlHelper Zend_Controller_Action_Helper_Url */
         $urlHelper = $controller->getHelper('url');
         $plxItemUrl = $item->isUrl() ? $item->getLink() : X_Env::completeUrl($urlHelper->url($item->getLink(), $item->getRoute(), $item->isReset()));
         $plxItem = new X_Plx_Item($plxItemName, $plxItemUrl, $plxItemType);
         if ($item->getThumbnail() != null) {
             if (X_Env::startWith($item->getThumbnail(), 'http') || X_Env::startWith($item->getThumbnail(), 'https')) {
                 $plxItem->setThumb($item->getThumbnail());
             } else {
                 $plxItem->setThumb(X_Env::completeUrl($item->getThumbnail()));
             }
         }
         if ($enhanced) {
             if ($plxItemWiimcplusIcon !== null) {
                 $plxItem->setWiimcplus_icon($plxItemWiimcplusIcon);
             }
             if ($item->getKey() == 'core-separator') {
                 $plxItem->setWiimcplus_assert_separator('true');
             }
             if ($item->getKey() == 'core-directwatch') {
                 $plxItem->setWiimcplus_assert_directwatch('true');
                 if ($item->getCustom('subtitle') != null) {
                     $plxItem->setWiimcplus_subtitle($item->getCustom('subtitle'));
                 }
             }
             if ($item->getKey() == 'core-play') {
                 $plxItem->setWiimcplus_assert_startvlc('true');
             }
         }
         $plx->addItem($plxItem);
     }
     $this->_render($plx, $controller);
 }
Example #13
0
 public function setParam($key, $value)
 {
     X_Vlc::getLastInstance()->registerArg($key, $value);
     return $this;
 }
Example #14
0
 public function postStartStreamer($started, X_Streamer_Engine $engine, $url, $provider, $location, Zend_Controller_Action $controller)
 {
     if ($engine instanceof X_Streamer_Engine_Vlc) {
         return $this->postSpawnVlc(X_Vlc::getLastInstance(), $provider, $location, $controller);
     } else {
         return $this->__call(__FUNCTION__, func_get_args());
     }
 }