Пример #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}\"");
     }
 }
Пример #3
0
 /**
  * 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");
     }
 }
Пример #4
0
 /**
  * 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");
     }
 }
Пример #5
0
 /**
  * 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}\"");
         }
     }
 }