public static function get_instance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new UserInputHandlerRegistry();
     }
     return self::$instance;
 }
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print('Vod favorites: handle_user_input:');
     foreach ($user_input as $key => $value) {
         hd_print("  {$key} => {$value}");
     }
     if ($user_input->control_id == 'popup_menu') {
         if (!isset($user_input->selected_media_url)) {
             return null;
         }
         $media_url = MediaURL::decode($user_input->selected_media_url);
         $movie_id = $media_url->movie_id;
         $is_favorite = $this->vod->is_favorite_movie_id($movie_id);
         $add_favorite_action = UserInputHandlerRegistry::create_action($this, 'add_favorite');
         $caption = 'Add to My Movies';
         $menu_items[] = array(GuiMenuItemDef::caption => $caption, GuiMenuItemDef::action => $add_favorite_action);
         return ActionFactory::show_popup_menu($menu_items);
     } else {
         if ($user_input->control_id == 'add_favorite') {
             if (!isset($user_input->selected_media_url)) {
                 return null;
             }
             $media_url = MediaURL::decode($user_input->selected_media_url);
             $movie_id = $media_url->movie_id;
             $is_favorite = $this->vod->is_favorite_movie_id($movie_id);
             if ($is_favorite) {
                 return ActionFactory::show_title_dialog('Movie already resides in My Movies');
             } else {
                 $this->vod->add_favorite_movie($movie_id, $plugin_cookies);
                 return ActionFactory::show_title_dialog('Movie has been added to My Movies');
             }
         }
     }
     return null;
 }
예제 #3
0
 public function get_action_map(MediaURL $media_url, &$plugin_cookies)
 {
     // hd_print(__METHOD__);
     $enter_action = ActionFactory::open_folder();
     $pop_up_action = UserInputHandlerRegistry::create_action($this, 'pop_up', null, 'Filtos');
     return array(GUI_EVENT_KEY_ENTER => $enter_action, GUI_EVENT_KEY_PLAY => $enter_action, GUI_EVENT_KEY_POPUP_MENU => $pop_up_action);
 }
예제 #4
0
 /**
  * override method to add 'playAll event'
  **/
 public function get_action_map(MediaURL $media_url, &$plugin_cookies)
 {
     UserInputHandlerRegistry::get_instance()->register_handler($this);
     $play_all_action = UserInputHandlerRegistry::create_action($this, 'playAll');
     $events = parent::get_action_map($media_url, $plugin_cookies);
     $events[GUI_EVENT_KEY_PLAY] = $play_all_action;
     hd_print(__METHOD__ . ':' . print_r($events, true));
     return $events;
 }
예제 #5
0
 public function __construct()
 {
     $this->tv = new ZTVTv();
     $this->add_screen(new TvGroupListScreen($this->tv, ZTVConfig::GET_TV_GROUP_LIST_FOLDER_VIEWS()));
     $this->add_screen(new TvChannelListScreen($this->tv, ZTVConfig::GET_TV_CHANNEL_LIST_FOLDER_VIEWS()));
     $this->add_screen(new TvFavoritesScreen($this->tv, ZTVConfig::GET_TV_CHANNEL_LIST_FOLDER_VIEWS()));
     $this->entry_handler = new ZTVSetupScreen();
     $this->add_screen($this->entry_handler);
     UserInputHandlerRegistry::get_instance()->register_handler($this->entry_handler);
 }
예제 #6
0
 public function get_action_map(MediaURL $media_url, &$plugin_cookies)
 {
     $move_backward_favorite_action = UserInputHandlerRegistry::create_action($this, 'move_backward_favorite');
     $move_backward_favorite_action['caption'] = 'Backward';
     $move_forward_favorite_action = UserInputHandlerRegistry::create_action($this, 'move_forward_favorite');
     $move_forward_favorite_action['caption'] = 'Forward';
     $remove_favorite_action = UserInputHandlerRegistry::create_action($this, 'remove_favorite');
     $remove_favorite_action['caption'] = 'Favorite';
     $menu_items[] = array(GuiMenuItemDef::caption => 'Remove from Favorites', GuiMenuItemDef::action => $remove_favorite_action);
     $popup_menu_action = ActionFactory::show_popup_menu($menu_items);
     return array(GUI_EVENT_KEY_ENTER => ActionFactory::tv_play(), GUI_EVENT_KEY_PLAY => ActionFactory::tv_play(), GUI_EVENT_KEY_B_GREEN => $move_backward_favorite_action, GUI_EVENT_KEY_C_YELLOW => $move_forward_favorite_action, GUI_EVENT_KEY_D_BLUE => $remove_favorite_action, GUI_EVENT_KEY_POPUP_MENU => $popup_menu_action);
 }
예제 #7
0
 public static function add_combobox(&$defs, $handler, $add_params, $name, $title, $initial_value, $value_caption_pairs, $width, $need_confirm = false, $need_apply = false)
 {
     $apply_action = null;
     if ($need_apply) {
         $apply_action = UserInputHandlerRegistry::create_action($handler, $name, $add_params);
         $apply_action['params']['action_type'] = 'apply';
     }
     $confirm_action = null;
     if ($need_confirm) {
         $confirm_action = UserInputHandlerRegistry::create_action($handler, $name, $add_params);
         $confirm_action['params']['action_type'] = 'confirm';
     }
     $defs[] = array(GuiControlDef::name => $name, GuiControlDef::title => $title, GuiControlDef::kind => GUI_CONTROL_COMBOBOX, GuiControlDef::specific_def => array(GuiComboboxDef::initial_value => $initial_value, GuiComboboxDef::value_caption_pairs => $value_caption_pairs, GuiComboboxDef::width => $width, GuiComboboxDef::apply_action => $apply_action, GuiComboboxDef::confirm_action => $confirm_action));
 }
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print('Tv favorites: handle_user_input:');
     foreach ($user_input as $key => $value) {
         hd_print("  {$key} => {$value}");
     }
     if ($user_input->control_id == 'info') {
         if (!isset($user_input->selected_media_url)) {
             return null;
         }
         $media_url = MediaURL::decode($user_input->selected_media_url);
         $channel_id = $media_url->channel_id;
         $channels = $this->tv->get_channels();
         $c = $channels->get($channel_id);
         $id = $c->get_id();
         $title = $c->get_title();
         return ActionFactory::show_title_dialog("Channel '{$title}' (id={$id})");
     } else {
         if ($user_input->control_id == 'popup_menu') {
             if (!isset($user_input->selected_media_url)) {
                 return null;
             }
             $media_url = MediaURL::decode($user_input->selected_media_url);
             $channel_id = $media_url->channel_id;
             $is_favorite = $this->tv->is_favorite_channel_id($channel_id, $plugin_cookies);
             $add_favorite_action = UserInputHandlerRegistry::create_action($this, 'add_favorite');
             $caption = 'Add to Favorites';
             $menu_items[] = array(GuiMenuItemDef::caption => $caption, GuiMenuItemDef::action => $add_favorite_action);
             return ActionFactory::show_popup_menu($menu_items);
         } else {
             if ($user_input->control_id == 'add_favorite') {
                 if (!isset($user_input->selected_media_url)) {
                     return null;
                 }
                 $media_url = MediaURL::decode($user_input->selected_media_url);
                 $channel_id = $media_url->channel_id;
                 $is_favorite = $this->tv->is_favorite_channel_id($channel_id, $plugin_cookies);
                 if ($is_favorite) {
                     return ActionFactory::show_title_dialog('Channel already resides in Favorites', $this->get_sel_item_update_action($user_input, $plugin_cookies));
                 } else {
                     $this->tv->change_tv_favorites(PLUGIN_FAVORITES_OP_ADD, $channel_id, $plugin_cookies);
                     return ActionFactory::show_title_dialog('Channel has been added to Favorites', $this->get_sel_item_update_action($user_input, $plugin_cookies));
                 }
             }
         }
     }
     return null;
 }
예제 #9
0
 public function get_action_map(MediaURL $media_url, &$plugin_cookies)
 {
     $actions = array();
     if ($this->vod->is_movie_page_supported()) {
         $actions[GUI_EVENT_KEY_ENTER] = ActionFactory::open_folder();
     } else {
         $actions[GUI_EVENT_KEY_ENTER] = ActionFactory::vod_play();
     }
     $remove_favorite_action = UserInputHandlerRegistry::create_action($this, 'remove_favorite');
     $remove_favorite_action['caption'] = 'Favorite';
     $menu_items[] = array(GuiMenuItemDef::caption => 'Remove from Favorites', GuiMenuItemDef::action => $remove_favorite_action);
     $popup_menu_action = ActionFactory::show_popup_menu($menu_items);
     $actions[GUI_EVENT_KEY_D_BLUE] = $remove_favorite_action;
     $actions[GUI_EVENT_KEY_POPUP_MENU] = $popup_menu_action;
     return $actions;
 }
 public function get_folder_view(MediaURL $media_url, &$plugin_cookies)
 {
     $this->vod->folder_entered($media_url, $plugin_cookies);
     $movie = $this->vod->get_loaded_movie($media_url->movie_id, $plugin_cookies);
     if ($movie === null) {
         // TODO: dialog?
         return null;
     }
     $has_right_button = $this->vod->is_favorites_supported();
     $right_button_caption = null;
     $right_button_action = null;
     if ($has_right_button) {
         $this->vod->ensure_favorites_loaded($plugin_cookies);
         $is_favorite = $this->vod->is_favorite_movie_id($movie->id);
         $right_button_caption = $is_favorite ? 'Remove from My Movies' : 'Add to My Movies';
         $right_button_action = UserInputHandlerRegistry::create_action($this, 'favorites', array('movie_id' => $movie->id));
     }
     $movie_folder_view = array(PluginMovieFolderView::movie => $movie->get_movie_array(), PluginMovieFolderView::has_right_button => $has_right_button, PluginMovieFolderView::right_button_caption => $right_button_caption, PluginMovieFolderView::right_button_action => $right_button_action, PluginMovieFolderView::has_multiple_series => count($movie->series_list) > 1, PluginMovieFolderView::series_media_url => VodSeriesListScreen::get_media_url_str($movie->id));
     return array(PluginFolderView::multiple_views_supported => false, PluginFolderView::archive => null, PluginFolderView::view_kind => PLUGIN_FOLDER_VIEW_MOVIE, PluginFolderView::data => $movie_folder_view);
 }
예제 #11
0
 public function get_folder_view(MediaURL $media_url, &$plugin_cookies)
 {
     hd_print(__METHOD__ . ': teste' . print_r($media_url, true));
     $this->vod->folder_entered($media_url, $plugin_cookies);
     $movie = $this->vod->get_loaded_movie($media_url->movie_id, $plugin_cookies);
     if ($movie === null) {
         // TODO: dialog?
         return null;
     }
     $has_right_button = $this->vod->is_favorites_supported();
     $right_button_caption = null;
     $right_button_action = null;
     if ($has_right_button) {
         $this->vod->ensure_favorites_loaded($plugin_cookies);
         $is_favorite = $this->vod->is_favorite_movie_id($movie->id);
         $right_button_caption = $is_favorite ? 'Remove from Favorites' : 'Add to Favorites';
         $right_button_action = UserInputHandlerRegistry::create_action($this, 'favorites', array('movie_id' => $movie->id));
     }
     $movie_folder_view = array(PluginMovieFolderView::movie => $movie->get_movie_array(), PluginMovieFolderView::has_right_button => $has_right_button, PluginMovieFolderView::right_button_caption => $right_button_caption, PluginMovieFolderView::right_button_action => $right_button_action, PluginMovieFolderView::has_multiple_series => count($movie->series_list) > 1, PluginMovieFolderView::series_media_url => VodSeriesListScreen::get_media_url_str($movie->id), PluginMovieFolderView::params => array(PluginFolderViewParams::paint_path_box => false, PluginFolderViewParams::paint_content_box_background => true));
     $a = array(PluginFolderView::multiple_views_supported => false, PluginFolderView::archive => null, PluginFolderView::view_kind => PLUGIN_FOLDER_VIEW_MOVIE, PluginFolderView::data => $movie_folder_view);
     // HD::print_backtrace();
     hd_print(__METHOD__ . ':' . print_r($a, true));
     return $a;
 }
예제 #12
0
 public function getPlexBaseUrl(&$plugin_cookies, $handler)
 {
     //    hd_print(__METHOD__ . ':' . print_r($plugin_cookies, true));
     // if ($currentPlexBaseUR) {
     //     return $currentPlexBaseUR;
     // }else {
     // hd_print(__METHOD__);
     $plexIp = $plugin_cookies->plexIp;
     $plexPort = $plugin_cookies->plexPort;
     //quick fix.
     //caso o usuário tenha instalado por cima de uma versão antiga que ainda não tenha esses items esses não são setados.
     //caso esses não sejam setados o plugin não consegue achar o conection type e com isso não sabe qual url usar.
     $connectionMethod = $plugin_cookies->connectionMethod ? $plugin_cookies->connectionMethod : HTTP_CONNECTION_TYPE;
     $hasSeenCaptionColor = $plugin_cookies->hasSeenCaptionColor ? $plugin_cookies->hasSeenCaptionColor : DEFAULT_HAS_SEEN_CAPTION_COLOR;
     $notSeenCaptionColor = $plugin_cookies->notSeenCaptionColor ? $plugin_cookies->notSeenCaptionColor : DEFAULT_NOT_SEEN_CAPTION_COLOR;
     if (!$plexIp || !$plexPort) {
         $btnSaveAction = UserInputHandlerRegistry::create_action($handler, 'savePref');
         throw new DuneException('Error: emplexer not configured, please go to setup and set ip and port', 0, ActionFactory::show_configuration_modal('configure your emplexer.', $plugin_cookies, $btnSaveAction));
     }
     //checa se precisa criar o cache_dir;
     EmplexerConfig::getInstance()->createCacheDirIfNeeded($plugin_cookies);
     return "http://{$plexIp}:{$plexPort}";
     // }
 }
예제 #13
0
 public function get_vod_info($media_url_str, &$plugin_cookies)
 {
     // hd_print(print_r(debug_backtrace(), true));
     HD::print_backtrace();
     $media_url = MediaURL::decode($media_url_str);
     hd_print(__METHOD__ . ': ' . print_r($media_url, true));
     if ($media_url->screen_id == 'emplexer_base_channel') {
         $toPlay = $media_url->video_media_array[$plugin_cookies->channel_selected_index];
         return EmplexerBaseChannel::get_vod_info($toPlay);
     }
     if ($media_url->screen_id == 'vod_movie') {
         return $this->vod->get_vod_info($media_url, $plugin_cookies);
         // EmplexerVod::get_vod_info($media_url, $plugin_cookies);
     }
     $handler = $media_url->back_screen_id == EmplexerVideoList::ID ? EmplexerVideoList::ID : EmplexerMovieList::ID;
     $params = array('key' => $media_url->key, 'back_screen_id' => $media_url->back_screen_id, 'back_key' => $media_url->back_key, 'back_filter_name' => $media_url->back_filter_name);
     $stop_action = UserInputHandlerRegistry::create_action($this->get_screen_by_id($handler), 'stop', $params);
     $time_action = UserInputHandlerRegistry::create_action($this->get_screen_by_id($handler), 'time', $params);
     $series_array = array();
     $series_array[] = array(PluginVodSeriesInfo::name => $media_url->title, PluginVodSeriesInfo::playback_url => $media_url->video_url, PluginVodSeriesInfo::playback_url_is_stream_url => true);
     $toBeReturned = array(PluginVodInfo::id => $media_url->movie_id, PluginVodInfo::series => $series_array, PluginVodInfo::name => $media_url->name, PluginVodInfo::description => $media_url->summary, PluginVodInfo::poster_url => $media_url->thumb, PluginVodInfo::initial_series_ndx => 0, PluginVodInfo::buffering_ms => 3000, PluginVodInfo::initial_position_ms => EmplexerVideoList::$viewOffset, PluginVodInfo::advert_mode => false, PluginVodInfo::timer => array(GuiTimerDef::delay_ms => 5000), PluginVodInfo::actions => array(GUI_EVENT_PLAYBACK_STOP => $stop_action, GUI_EVENT_TIMER => $time_action));
     hd_print(print_r($toBeReturned, true));
     return $toBeReturned;
 }
예제 #14
0
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print(__METHOD__ . ':' . print_r($user_input, true));
     if ($user_input->selected_control_id == 'configureNfs') {
         $saveAdvanceNfsConfig = UserInputHandlerRegistry::create_action($this, 'saveAdvanceNfsConfig');
         return ActionFactory::show_nfs_advanced_configuration_modal('Nfs advanced configuration', &$plugin_cookies, $saveAdvanceNfsConfig);
     } else {
         if ($user_input->selected_control_id == 'configureSMB') {
             $saveAdvanceSmbConfig = UserInputHandlerRegistry::create_action($this, 'saveAdvanceSmbConfig');
             return ActionFactory::show_smb_advanced_configuration_modal('SMB advanced configuration', &$plugin_cookies, $saveAdvanceSmbConfig);
         } else {
             if ($user_input->selected_control_id == 'btnDefaultFilter') {
                 $saveDefaultFilters = UserInputHandlerRegistry::create_action($this, 'saveDefaultFilters');
                 return ActionFactory::show_default_filter_selecor_modal('Default filters configuration', &$plugin_cookies, $saveDefaultFilters);
             } else {
                 if ($user_input->selected_control_id == 'btnSalvar') {
                     return EmplexerSetupScreen::savePreferences($user_input, $plugin_cookies, ActionFactory::reset_controls($this->do_get_control_defs($plugin_cookies)));
                 } else {
                     if ($user_input->selected_control_id == 'connectionMethod') {
                         if ($user_input->connectionMethod == NFS_CONNECTION_TYPE) {
                             $saveAdvanceNfsConfig = UserInputHandlerRegistry::create_action($this, 'saveAdvanceNfsConfig');
                             return ActionFactory::show_nfs_advanced_configuration_modal('Nfs advanced configuration', &$plugin_cookies, $saveAdvanceNfsConfig);
                         } else {
                             if ($user_input->connectionMethod == SMB_CONNECTION_TYPE) {
                                 $saveAdvanceSmbConfig = UserInputHandlerRegistry::create_action($this, 'saveAdvanceSmbConfig');
                                 return ActionFactory::show_smb_advanced_configuration_modal('SMB advanced configuration', &$plugin_cookies, $saveAdvanceSmbConfig);
                             } else {
                                 EmplexerSetupScreen::savePreferences($user_input, $plugin_cookies);
                                 return ActionFactory::reset_controls($this->do_get_control_defs($plugin_cookies));
                             }
                         }
                     } else {
                         if ($user_input->selected_control_id == 'saveDefaultFilters') {
                             EmplexerSetupScreen::savePreferences($user_input, $plugin_cookies);
                             return ActionFactory::reset_controls($this->do_get_control_defs($plugin_cookies));
                         } else {
                             if ($user_input->selected_control_id == 'saveAdvanceNfs') {
                                 EmplexerSetupScreen::savePreferences($user_input, $plugin_cookies);
                                 return ActionFactory::reset_controls($this->do_get_control_defs($plugin_cookies));
                             } else {
                                 if ($user_input->selected_control_id == 'saveAdvanceSmb') {
                                     EmplexerSetupScreen::savePreferences($user_input, $plugin_cookies);
                                     return ActionFactory::reset_controls($this->do_get_control_defs($plugin_cookies));
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 public function __construct($session)
 {
     $this->session = $session;
     UserInputHandlerRegistry::get_instance()->register_handler($this);
 }
 public function __construct()
 {
     UserInputHandlerRegistry::get_instance()->register_handler($this);
 }
 protected function __construct($id)
 {
     $this->id = $id;
     UserInputHandlerRegistry::get_instance()->register_handler($this);
 }
예제 #18
0
 public function get_action_map(MediaURL $media_url, &$plugin_cookies)
 {
     $select_genre_action = UserInputHandlerRegistry::create_action($this, 'select_genre');
     return array(GUI_EVENT_KEY_ENTER => $select_genre_action);
 }
예제 #19
0
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     return UserInputHandlerRegistry::get_instance()->handle_user_input($user_input, $plugin_cookies);
 }
예제 #20
0
 public function get_action_map(MediaURL $media_url, &$plugin_cookies)
 {
     // hd_print(__METHOD__);
     UserInputHandlerRegistry::get_instance()->register_handler($this);
     $show_resume_menu_action = UserInputHandlerRegistry::create_action($this, 'show_resume_menu');
     $info_action = UserInputHandlerRegistry::create_action($this, 'info');
     $pop_up_action = UserInputHandlerRegistry::create_action($this, 'pop_up', null, 'Filtos');
     $a = array(GUI_EVENT_KEY_ENTER => $show_resume_menu_action, GUI_EVENT_KEY_PLAY => $show_resume_menu_action, GUI_EVENT_KEY_POPUP_MENU => $pop_up_action, GUI_EVENT_KEY_INFO => $info_action);
     // hd_print(print_r($a, true));
     return $a;
 }
예제 #21
0
 public function doEnterVideo(&$user_input)
 {
     hd_print(__METHOD__);
     $media_url = MediaURL::decode($user_input->selected_media_url);
     $pop_up_items = array();
     $index = 0;
     foreach ($media_url->video_media_array as $m) {
         $name = $m->width . 'x' . $m->height;
         if ($m->bitrate) {
             $name .= '-' . $m->bitrate;
         }
         $params['index'] = $index++;
         $pop_up_items[] = array(GuiMenuItemDef::caption => $name, GuiMenuItemDef::action => UserInputHandlerRegistry::create_action($this, 'play', $params));
     }
     if (count($pop_up_items) > 0) {
         return ActionFactory::show_popup_menu($pop_up_items);
     }
 }