Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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 jmarshallnz authored
View
30 xbmc/Util.cpp
@@ -1095,14 +1095,14 @@ void CUtil::SplitParams(const CStdString &paramString, std::vector<CStdString> &
lastEscaped = escaped;
if (inQuotes)
{ // if we're in a quote, we accept everything until the closing quote
- if (ch == '\"' && !escaped)
+ if (ch == '"' && !escaped)
{ // finished a quote - no need to add the end quote to our string
inQuotes = false;
}
}
else
{ // not in a quote, so check if we should be starting one
- if (ch == '\"' && !escaped)
+ if (ch == '"' && !escaped)
{ // start of quote - no need to add the quote to our string
inQuotes = true;
}
@@ -1119,15 +1119,25 @@ void CUtil::SplitParams(const CStdString &paramString, std::vector<CStdString> &
if (whiteSpacePos)
parameter = parameter.Left(whiteSpacePos);
// trim off start and end quotes
- if (parameter.GetLength() > 1 && parameter[0] == '\"' && parameter[parameter.GetLength() - 1] == '\"')
+ if (parameter.GetLength() > 1 && parameter[0] == '"' && parameter[parameter.GetLength() - 1] == '"')
parameter = parameter.Mid(1,parameter.GetLength() - 2);
+ else if (parameter.GetLength() > 3 && parameter[parameter.GetLength() - 1] == '"')
+ {
+ // check name="value" style param.
+ int quotaPos = parameter.Find('"');
+ if (quotaPos > 1 && quotaPos < parameter.GetLength() - 1 && parameter[quotaPos - 1] == '=')
+ {
+ parameter.Delete(parameter.GetLength() - 1);
+ parameter.Delete(quotaPos);
+ }
+ }
parameters.push_back(parameter);
parameter.Empty();
whiteSpacePos = 0;
continue;
}
}
- if ((ch == '\"' || ch == '\\') && escaped)
+ if ((ch == '"' || ch == '\\') && escaped)
{ // escaped quote or backslash
parameter[parameter.size()-1] = ch;
continue;
@@ -1149,8 +1159,18 @@ void CUtil::SplitParams(const CStdString &paramString, std::vector<CStdString> &
if (whiteSpacePos)
parameter = parameter.Left(whiteSpacePos);
// trim off start and end quotes
- if (parameter.GetLength() > 1 && parameter[0] == '\"' && parameter[parameter.GetLength() - 1] == '\"')
+ if (parameter.GetLength() > 1 && parameter[0] == '"' && parameter[parameter.GetLength() - 1] == '"')
parameter = parameter.Mid(1,parameter.GetLength() - 2);
+ else if (parameter.GetLength() > 3 && parameter[parameter.GetLength() - 1] == '"')
+ {
+ // check name="value" style param.
+ int quotaPos = parameter.Find('"');
+ if (quotaPos > 1 && quotaPos < parameter.GetLength() - 1 && parameter[quotaPos - 1] == '=')
+ {
+ parameter.Delete(parameter.GetLength() - 1);
+ parameter.Delete(quotaPos);
+ }
+ }
if (!parameter.IsEmpty() || parameters.size())
parameters.push_back(parameter);
}
View
29 xbmc/interfaces/Builtins.cpp
@@ -642,24 +642,37 @@ int CBuiltins::Execute(const CStdString& execString)
CLog::Log(LOGERROR, "XBMC.SlideShow called with empty parameter");
return -2;
}
+ std::string beginSlidePath;
// leave RecursiveSlideShow command as-is
unsigned int flags = 0;
if (execute.Equals("RecursiveSlideShow"))
flags |= 1;
- // SlideShow(dir[,recursive][,[not]random])
+ // SlideShow(dir[,recursive][,[not]random][,pause][,beginslide="/path/to/start/slide.jpg"])
+ // the beginslide value need be escaped (for '"' or '\' in it, by backslash)
+ // and then quoted, or not. See CUtil::SplitParams()
else
{
- if ((params.size() > 1 && params[1] == "recursive") || (params.size() > 2 && params[2] == "recursive"))
- flags |= 1;
- if ((params.size() > 1 && params[1] == "random") || (params.size() > 2 && params[2] == "random"))
- flags |= 2;
- if ((params.size() > 1 && params[1] == "notrandom") || (params.size() > 2 && params[2] == "notrandom"))
- flags |= 4;
+ for (unsigned int i = 1 ; i < params.size() ; i++)
+ {
+ if (params[i].Equals("recursive"))
+ flags |= 1;
+ else if (params[i].Equals("random")) // set fullscreen or windowed
+ flags |= 2;
+ else if (params[i].Equals("notrandom"))
+ flags |= 4;
+ else if (params[i].Equals("pause"))
+ flags |= 8;
+ else if (params[i].Left(11).Equals("beginslide="))
+ beginSlidePath = params[i].Mid(11);
+ }
}
CGUIMessage msg(GUI_MSG_START_SLIDESHOW, 0, 0, flags);
- msg.SetStringParam(params[0]);
+ vector<CStdString> strParams;
+ strParams.push_back(params[0]);
+ strParams.push_back(beginSlidePath);
+ msg.SetStringParams(strParams);
CGUIWindow *pWindow = g_windowManager.GetWindow(WINDOW_SLIDESHOW);
if (pWindow) pWindow->OnMessage(msg);
}
View
29 xbmc/pictures/GUIWindowSlideShow.cpp
@@ -864,10 +864,12 @@ bool CGUIWindowSlideShow::OnMessage(CGUIMessage& message)
{
CStdString strFolder = message.GetStringParam();
unsigned int iParams = message.GetParam1();
+ std::string beginSlidePath = message.GetStringParam(1);
//decode params
bool bRecursive = false;
bool bRandom = false;
bool bNotRandom = false;
+ bool bPause = false;
if (iParams > 0)
{
if ((iParams & 1) == 1)
@@ -876,8 +878,10 @@ bool CGUIWindowSlideShow::OnMessage(CGUIMessage& message)
bRandom = true;
if ((iParams & 4) == 4)
bNotRandom = true;
+ if ((iParams & 8) == 8)
+ bPause = true;
}
- RunSlideShow(strFolder, bRecursive, bRandom, bNotRandom);
+ RunSlideShow(strFolder, bRecursive, bRandom, bNotRandom, SORT_METHOD_LABEL, SortOrderAscending, "", beginSlidePath, !bPause);
}
break;
@@ -1091,7 +1095,8 @@ void CGUIWindowSlideShow::AddFromPath(const CStdString &strPath,
void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath,
bool bRecursive /* = false */, bool bRandom /* = false */,
bool bNotRandom /* = false */, SORT_METHOD method /* = SORT_METHOD_LABEL */,
- SortOrder order /* = SortOrderAscending */, const CStdString &strExtensions)
+ SortOrder order /* = SortOrderAscending */, const CStdString &strExtensions /* = "" */,
+ const CStdString &beginSlidePath /* = "" */, bool startSlideShow /* = true */)
{
// stop any video
if (g_application.IsPlayingVideo())
@@ -1099,6 +1104,9 @@ void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath,
AddFromPath(strPath, bRecursive, method, order, strExtensions);
+ if (!NumSlides())
+ return;
+
// mutually exclusive options
// if both are set, clear both and use the gui setting
if (bRandom && bNotRandom)
@@ -1108,9 +1116,20 @@ void CGUIWindowSlideShow::RunSlideShow(const CStdString &strPath,
if ((!bNotRandom && g_guiSettings.GetBool("slideshow.shuffle")) || bRandom)
Shuffle();
- StartSlideShow();
- if (NumSlides())
- g_windowManager.ActivateWindow(WINDOW_SLIDESHOW);
+ if (!beginSlidePath.IsEmpty())
+ Select(beginSlidePath);
+
+ if (startSlideShow)
+ StartSlideShow();
+ else
+ {
+ CVariant param;
+ param["player"]["speed"] = 0;
+ param["player"]["playerid"] = PLAYLIST_PICTURE;
+ ANNOUNCEMENT::CAnnouncementManager::Announce(ANNOUNCEMENT::Player, "xbmc", "OnPlay", GetCurrentSlide(), param);
+ }
+
+ g_windowManager.ActivateWindow(WINDOW_SLIDESHOW);
}
void CGUIWindowSlideShow::AddItems(const CStdString &strPath, path_set *recursivePaths, SORT_METHOD method, SortOrder order)
View
3  xbmc/pictures/GUIWindowSlideShow.h
@@ -76,7 +76,8 @@ class CGUIWindowSlideShow : public CGUIWindow
void RunSlideShow(const CStdString &strPath, bool bRecursive = false,
bool bRandom = false, bool bNotRandom = false,
SORT_METHOD method = SORT_METHOD_LABEL,
- SortOrder order = SortOrderAscending, const CStdString &strExtensions="");
+ SortOrder order = SortOrderAscending, const CStdString &strExtensions="",
+ const CStdString &beginSlidePath="", bool startSlideShow = true);
void AddFromPath(const CStdString &strPath, bool bRecursive,
SORT_METHOD method=SORT_METHOD_LABEL,
SortOrder order = SortOrderAscending, const CStdString &strExtensions="");
Please sign in to comment.
Something went wrong with that request. Please try again.