fixed: switch channels using keypad while watching slingbox (fixes Ticket #14961)
authorwsoltys <wiso@no.way>
Fri, 14 Mar 2014 18:51:16 +0000 (19:51 +0100)
committerwsoltys <wiso@no.way>
Fri, 14 Mar 2014 18:51:16 +0000 (19:51 +0100)
xbmc/video/windows/GUIWindowFullScreen.cpp

index 92919e0..8b88704 100644 (file)
@@ -236,42 +236,57 @@ bool CGUIWindowFullScreen::OnAction(const CAction &action)
     {
       if (g_application.CurrentFileItem().IsLiveTV())
       {
-        CPVRChannelPtr playingChannel;
-        if(!g_PVRManager.GetCurrentChannel(playingChannel))
-          return false;
-
-        if (action.GetID() == REMOTE_0)
+        if(CPVRManager::Get().IsPlaying())
         {
-          CPVRChannelGroupPtr group = g_PVRChannelGroups->GetPreviousPlayedGroup();
-          if (group)
+          // pvr client addon
+          CPVRChannelPtr playingChannel;
+          if(!g_PVRManager.GetCurrentChannel(playingChannel))
+            return false;
+
+          if (action.GetID() == REMOTE_0)
           {
-            g_PVRManager.SetPlayingGroup(group);
-            CFileItemPtr fileItem = group->GetLastPlayedChannel(playingChannel->ChannelID());
-            if (fileItem && fileItem->HasPVRChannelInfoTag())
+            CPVRChannelGroupPtr group = g_PVRChannelGroups->GetPreviousPlayedGroup();
+            if (group)
             {
-              CLog::Log(LOGDEBUG, "%s - switch to channel number %d", __FUNCTION__, fileItem->GetPVRChannelInfoTag()->ChannelNumber());
-              g_application.OnAction(CAction(ACTION_CHANNEL_SWITCH, (float) fileItem->GetPVRChannelInfoTag()->ChannelNumber()));
+              g_PVRManager.SetPlayingGroup(group);
+              CFileItemPtr fileItem = group->GetLastPlayedChannel(playingChannel->ChannelID());
+              if (fileItem && fileItem->HasPVRChannelInfoTag())
+              {
+                CLog::Log(LOGDEBUG, "%s - switch to channel number %d", __FUNCTION__, fileItem->GetPVRChannelInfoTag()->ChannelNumber());
+                g_application.OnAction(CAction(ACTION_CHANNEL_SWITCH, (float) fileItem->GetPVRChannelInfoTag()->ChannelNumber()));
+              }
             }
           }
-        }
-        else
-        {
-          int autoCloseTime = CSettings::Get().GetBool("pvrplayback.confirmchannelswitch") ? 0 : g_advancedSettings.m_iPVRNumericChannelSwitchTimeout;
-          CStdString strChannel = StringUtils::Format("%i", action.GetID() - REMOTE_0);
-          if (CGUIDialogNumeric::ShowAndGetNumber(strChannel, g_localizeStrings.Get(19000), autoCloseTime) || autoCloseTime)
+          else
           {
-            int iChannelNumber = atoi(strChannel.c_str());
-            if (iChannelNumber > 0 && iChannelNumber != playingChannel->ChannelNumber())
+            int autoCloseTime = CSettings::Get().GetBool("pvrplayback.confirmchannelswitch") ? 0 : g_advancedSettings.m_iPVRNumericChannelSwitchTimeout;
+            CStdString strChannel = StringUtils::Format("%i", action.GetID() - REMOTE_0);
+            if (CGUIDialogNumeric::ShowAndGetNumber(strChannel, g_localizeStrings.Get(19000), autoCloseTime) || autoCloseTime)
             {
-              CPVRChannelGroupPtr selectedGroup = g_PVRManager.GetPlayingGroup(playingChannel->IsRadio());
-              CFileItemPtr channel = selectedGroup->GetByChannelNumber(iChannelNumber);
-              if (!channel || !channel->HasPVRChannelInfoTag())
-                return false;
+              int iChannelNumber = atoi(strChannel.c_str());
+              if (iChannelNumber > 0 && iChannelNumber != playingChannel->ChannelNumber())
+              {
+                CPVRChannelGroupPtr selectedGroup = g_PVRManager.GetPlayingGroup(playingChannel->IsRadio());
+                CFileItemPtr channel = selectedGroup->GetByChannelNumber(iChannelNumber);
+                if (!channel || !channel->HasPVRChannelInfoTag())
+                  return false;
 
-              g_application.OnAction(CAction(ACTION_CHANNEL_SWITCH, (float)iChannelNumber));
+                g_application.OnAction(CAction(ACTION_CHANNEL_SWITCH, (float)iChannelNumber));
+              }
             }
           }
         }
+        else
+        {
+          // filesystem provider like slingbox, cmyth, etc
+          int iChannelNumber = -1;
+          CStdString strChannel = StringUtils::Format("%i", action.GetID() - REMOTE_0);
+          if (CGUIDialogNumeric::ShowAndGetNumber(strChannel, g_localizeStrings.Get(19000)))
+            iChannelNumber = atoi(strChannel.c_str());
+            
+          if (iChannelNumber > 0)
+            g_application.OnAction(CAction(ACTION_CHANNEL_SWITCH, (float)iChannelNumber));
+        }
       }
       else
       {