Skip to content
This repository
Browse code

Merge pull request #2543 from ulion/enhanced_builtin_slideshow

Enhanced builtin func SlideShow() support pause and set beginslide path
  • Loading branch information...
commit 425fd3ef81d402be66182d46e1d363a06d4ebe8f 2 parents 5de5933 + cc67a07
jmarshallnz authored
30  xbmc/Util.cpp
@@ -1095,14 +1095,14 @@ void CUtil::SplitParams(const CStdString &paramString, std::vector<CStdString> &
1095 1095
     lastEscaped = escaped;
1096 1096
     if (inQuotes)
1097 1097
     { // if we're in a quote, we accept everything until the closing quote
1098  
-      if (ch == '\"' && !escaped)
  1098
+      if (ch == '"' && !escaped)
1099 1099
       { // finished a quote - no need to add the end quote to our string
1100 1100
         inQuotes = false;
1101 1101
       }
1102 1102
     }
1103 1103
     else
1104 1104
     { // not in a quote, so check if we should be starting one
1105  
-      if (ch == '\"' && !escaped)
  1105
+      if (ch == '"' && !escaped)
1106 1106
       { // start of quote - no need to add the quote to our string
1107 1107
         inQuotes = true;
1108 1108
       }
@@ -1119,15 +1119,25 @@ void CUtil::SplitParams(const CStdString &paramString, std::vector<CStdString> &
1119 1119
         if (whiteSpacePos)
1120 1120
           parameter = parameter.Left(whiteSpacePos);
1121 1121
         // trim off start and end quotes
1122  
-        if (parameter.GetLength() > 1 && parameter[0] == '\"' && parameter[parameter.GetLength() - 1] == '\"')
  1122
+        if (parameter.GetLength() > 1 && parameter[0] == '"' && parameter[parameter.GetLength() - 1] == '"')
1123 1123
           parameter = parameter.Mid(1,parameter.GetLength() - 2);
  1124
+        else if (parameter.GetLength() > 3 && parameter[parameter.GetLength() - 1] == '"')
  1125
+        {
  1126
+          // check name="value" style param.
  1127
+          int quotaPos = parameter.Find('"');
  1128
+          if (quotaPos > 1 && quotaPos < parameter.GetLength() - 1 && parameter[quotaPos - 1] == '=')
  1129
+          {
  1130
+            parameter.Delete(parameter.GetLength() - 1);
  1131
+            parameter.Delete(quotaPos);
  1132
+          }
  1133
+        }
1124 1134
         parameters.push_back(parameter);
1125 1135
         parameter.Empty();
1126 1136
         whiteSpacePos = 0;
1127 1137
         continue;
1128 1138
       }
1129 1139
     }
1130  
-    if ((ch == '\"' || ch == '\\') && escaped)
  1140
+    if ((ch == '"' || ch == '\\') && escaped)
1131 1141
     { // escaped quote or backslash
1132 1142
       parameter[parameter.size()-1] = ch;
1133 1143
       continue;
@@ -1149,8 +1159,18 @@ void CUtil::SplitParams(const CStdString &paramString, std::vector<CStdString> &
1149 1159
   if (whiteSpacePos)
1150 1160
     parameter = parameter.Left(whiteSpacePos);
1151 1161
   // trim off start and end quotes
1152  
-  if (parameter.GetLength() > 1 && parameter[0] == '\"' && parameter[parameter.GetLength() - 1] == '\"')
  1162
+  if (parameter.GetLength() > 1 && parameter[0] == '"' && parameter[parameter.GetLength() - 1] == '"')
1153 1163
     parameter = parameter.Mid(1,parameter.GetLength() - 2);
  1164
+  else if (parameter.GetLength() > 3 && parameter[parameter.GetLength() - 1] == '"')
  1165
+  {
  1166
+    // check name="value" style param.
  1167
+    int quotaPos = parameter.Find('"');
  1168
+    if (quotaPos > 1 && quotaPos < parameter.GetLength() - 1 && parameter[quotaPos - 1] == '=')
  1169
+    {
  1170
+      parameter.Delete(parameter.GetLength() - 1);
  1171
+      parameter.Delete(quotaPos);
  1172
+    }
  1173
+  }
1154 1174
   if (!parameter.IsEmpty() || parameters.size())
1155 1175
     parameters.push_back(parameter);
1156 1176
 }
29  xbmc/interfaces/Builtins.cpp
@@ -642,24 +642,37 @@ int CBuiltins::Execute(const CStdString& execString)
642 642
       CLog::Log(LOGERROR, "XBMC.SlideShow called with empty parameter");
643 643
       return -2;
644 644
     }
  645
+    std::string beginSlidePath;
645 646
     // leave RecursiveSlideShow command as-is
646 647
     unsigned int flags = 0;
647 648
     if (execute.Equals("RecursiveSlideShow"))
648 649
       flags |= 1;
649 650
 
650  
-    // SlideShow(dir[,recursive][,[not]random])
  651
+    // SlideShow(dir[,recursive][,[not]random][,pause][,beginslide="/path/to/start/slide.jpg"])
  652
+    // the beginslide value need be escaped (for '"' or '\' in it, by backslash)
  653
+    // and then quoted, or not. See CUtil::SplitParams()
651 654
     else
652 655
     {
653  
-      if ((params.size() > 1 && params[1] == "recursive") || (params.size() > 2 && params[2] == "recursive"))
654  
-        flags |= 1;
655  
-      if ((params.size() > 1 && params[1] == "random") || (params.size() > 2 && params[2] == "random"))
656  
-        flags |= 2;
657  
-      if ((params.size() > 1 && params[1] == "notrandom") || (params.size() > 2 && params[2] == "notrandom"))
658  
-        flags |= 4;
  656
+      for (unsigned int i = 1 ; i < params.size() ; i++)
  657
+      {
  658
+        if (params[i].Equals("recursive"))
  659
+          flags |= 1;
  660
+        else if (params[i].Equals("random")) // set fullscreen or windowed
  661
+          flags |= 2;
  662
+        else if (params[i].Equals("notrandom"))
  663
+          flags |= 4;
  664
+        else if (params[i].Equals("pause"))
  665
+          flags |= 8;
  666
+        else if (params[i].Left(11).Equals("beginslide="))
  667
+          beginSlidePath = params[i].Mid(11);
  668
+      }
659 669
     }
660 670
 
661 671
     CGUIMessage msg(GUI_MSG_START_SLIDESHOW, 0, 0, flags);
662  
-    msg.SetStringParam(params[0]);
  672
+    vector<CStdString> strParams;
  673
+    strParams.push_back(params[0]);
  674
+    strParams.push_back(beginSlidePath);
  675
+    msg.SetStringParams(strParams);
663 676
     CGUIWindow *pWindow = g_windowManager.GetWindow(WINDOW_SLIDESHOW);
664 677
     if (pWindow) pWindow->OnMessage(msg);
665 678
   }
29  xbmc/pictures/GUIWindowSlideShow.cpp
@@ -864,10 +864,12 @@ bool CGUIWindowSlideShow::OnMessage(CGUIMessage& message)
864 864
     {
865 865
       CStdString strFolder = message.GetStringParam();
866 866
       unsigned int iParams = message.GetParam1();
  867
+      std::string beginSlidePath = message.GetStringParam(1);
867 868
       //decode params
868 869
       bool bRecursive = false;
869 870
       bool bRandom = false;
870 871
       bool bNotRandom = false;
  872
+      bool bPause = false;
871 873
       if (iParams > 0)
872 874
       {
873 875
         if ((iParams & 1) == 1)
@@ -876,8 +878,10 @@ bool CGUIWindowSlideShow::OnMessage(CGUIMessage& message)
876 878
           bRandom = true;
877 879
         if ((iParams & 4) == 4)
878 880
           bNotRandom = true;
  881
+        if ((iParams & 8) == 8)
  882
+          bPause = true;
879 883
       }
880  
-      RunSlideShow(strFolder, bRecursive, bRandom, bNotRandom);
  884
+      RunSlideShow(strFolder, bRecursive, bRandom, bNotRandom, SORT_METHOD_LABEL, SortOrderAscending, "", beginSlidePath, !bPause);
881 885
     }
882 886
     break;
883 887
 
@@ -1091,7 +1095,8 @@ void CGUIWindowSlideShow::AddFromPath(const CStdString &strPath,
1091 1095
 void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath, 
1092 1096
                                        bool bRecursive /* = false */, bool bRandom /* = false */, 
1093 1097
                                        bool bNotRandom /* = false */, SORT_METHOD method /* = SORT_METHOD_LABEL */, 
1094  
-                                       SortOrder order /* = SortOrderAscending */, const CStdString &strExtensions)
  1098
+                                       SortOrder order /* = SortOrderAscending */, const CStdString &strExtensions /* = "" */,
  1099
+                                       const CStdString &beginSlidePath /* = "" */, bool startSlideShow /* = true */)
1095 1100
 {
1096 1101
   // stop any video
1097 1102
   if (g_application.IsPlayingVideo())
@@ -1099,6 +1104,9 @@ void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath,
1099 1104
 
1100 1105
   AddFromPath(strPath, bRecursive, method, order, strExtensions);
1101 1106
 
  1107
+  if (!NumSlides())
  1108
+    return;
  1109
+
1102 1110
   // mutually exclusive options
1103 1111
   // if both are set, clear both and use the gui setting
1104 1112
   if (bRandom && bNotRandom)
@@ -1108,9 +1116,20 @@ void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath,
1108 1116
   if ((!bNotRandom && g_guiSettings.GetBool("slideshow.shuffle")) || bRandom)
1109 1117
     Shuffle();
1110 1118
 
1111  
-  StartSlideShow();
1112  
-  if (NumSlides())
1113  
-    g_windowManager.ActivateWindow(WINDOW_SLIDESHOW);
  1119
+  if (!beginSlidePath.IsEmpty())
  1120
+    Select(beginSlidePath);
  1121
+
  1122
+  if (startSlideShow)
  1123
+    StartSlideShow();
  1124
+  else 
  1125
+  {
  1126
+    CVariant param;
  1127
+    param["player"]["speed"] = 0;
  1128
+    param["player"]["playerid"] = PLAYLIST_PICTURE;
  1129
+    ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::Player, "xbmc", "OnPlay", GetCurrentSlide(), param);
  1130
+  }
  1131
+
  1132
+  g_windowManager.ActivateWindow(WINDOW_SLIDESHOW);
1114 1133
 }
1115 1134
 
1116 1135
 void CGUIWindowSlideShow::AddItems(const CStdString &strPath, path_set *recursivePaths, SORT_METHOD method, SortOrder order)
3  xbmc/pictures/GUIWindowSlideShow.h
@@ -76,7 +76,8 @@ class CGUIWindowSlideShow : public CGUIWindow
76 76
   void RunSlideShow(const CStdString &strPath, bool bRecursive = false,
77 77
                     bool bRandom = false, bool bNotRandom = false,
78 78
                     SORT_METHOD method = SORT_METHOD_LABEL,
79  
-                    SortOrder order = SortOrderAscending, const CStdString &strExtensions="");
  79
+                    SortOrder order = SortOrderAscending, const CStdString &strExtensions="",
  80
+                    const CStdString &beginSlidePath="", bool startSlideShow = true);
80 81
   void AddFromPath(const CStdString &strPath, bool bRecursive,
81 82
                    SORT_METHOD method=SORT_METHOD_LABEL, 
82 83
                    SortOrder order = SortOrderAscending, const CStdString &strExtensions="");

0 notes on commit 425fd3e

Please sign in to comment.
Something went wrong with that request. Please try again.