Permalink
Browse files

jsonrpc: always start a slideshow through the appmessenger (fixes #12947

)
  • Loading branch information...
1 parent f52dd9a commit 5f8739199720b655acad62c98b1889045389bda8 @Montellese Montellese committed Apr 22, 2012
Showing with 17 additions and 40 deletions.
  1. +16 −39 xbmc/interfaces/json-rpc/PlayerOperations.cpp
  2. +1 −1 xbmc/interfaces/json-rpc/PlayerOperations.h
@@ -481,32 +481,17 @@ JSONRPC_STATUS CPlayerOperations::Open(const CStdString &method, ITransportLayer
break;
case PLAYLIST_PICTURE:
- return StartSlideshow();
+ return StartSlideshow("", false, optionShuffled.isBoolean() && optionShuffled.asBoolean());
break;
}
return ACK;
}
else if (parameterObject["item"].isObject() && parameterObject["item"].isMember("path"))
{
- CStdString exec = "slideShow(";
-
- exec += parameterObject["item"]["path"].asString();
-
- if ((optionShuffled.isBoolean() && optionShuffled.asBoolean()) ||
- (!optionShuffled.isBoolean() && parameterObject["item"]["random"].asBoolean()))
- exec += ", random";
- else
- exec += ", notrandom";
-
- if (parameterObject["item"]["recursive"].asBoolean())
- exec += ", recursive";
-
- exec += ")";
- ThreadMessage msg = { TMSG_EXECUTE_BUILT_IN, (DWORD)0, (DWORD)0, exec };
- g_application.getApplicationMessenger().SendMessage(msg);
-
- return ACK;
+ bool random = (optionShuffled.isBoolean() && optionShuffled.asBoolean()) ||
+ (!optionShuffled.isBoolean() && parameterObject["item"]["random"].asBoolean());
+ return StartSlideshow(parameterObject["item"]["path"].asString(), parameterObject["item"]["recursive"].asBoolean(), random);
}
else
{
@@ -534,10 +519,7 @@ JSONRPC_STATUS CPlayerOperations::Open(const CStdString &method, ITransportLayer
for (int index = 0; index < list.Size(); index++)
slideshow->Add(list[index].get());
- if (optionShuffled.isBoolean() && optionShuffled.asBoolean())
- slideshow->Shuffle();
-
- return StartSlideshow();
+ return StartSlideshow("", false, optionShuffled.isBoolean() && optionShuffled.asBoolean());
}
else
{
@@ -865,24 +847,19 @@ int CPlayerOperations::GetPlaylist(PlayerType player)
}
}
-JSONRPC_STATUS CPlayerOperations::StartSlideshow()
+JSONRPC_STATUS CPlayerOperations::StartSlideshow(const std::string path, bool recursive, bool random)
{
- CGUIWindowSlideShow *slideshow = (CGUIWindowSlideShow*)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
- if (!slideshow || slideshow->NumSlides() <= 0)
- return FailedToExecute;
-
- if (g_application.IsPlayingVideo())
- g_application.StopPlaying();
-
- g_graphicsContext.Lock();
-
- g_application.WakeUpScreenSaverAndDPMS();
- slideshow->StartSlideShow();
-
- if (g_windowManager.GetActiveWindow() != WINDOW_SLIDESHOW)
- g_windowManager.ActivateWindow(WINDOW_SLIDESHOW);
+ int flags = 0;
+ if (recursive)
+ flags |= 1;
+ if (random)
+ flags |= 2;
+ else
+ flags |= 4;
- g_graphicsContext.Unlock();
+ CGUIMessage msg(GUI_MSG_START_SLIDESHOW, 0, 0, flags);
+ msg.SetStringParam(path);
+ g_application.getApplicationMessenger().SendGUIMessage(msg, WINDOW_SLIDESHOW, true);
return ACK;
}
@@ -72,7 +72,7 @@ namespace JSONRPC
static int GetActivePlayers();
static PlayerType GetPlayer(const CVariant &player);
static int GetPlaylist(PlayerType player);
- static JSONRPC_STATUS StartSlideshow();
+ static JSONRPC_STATUS StartSlideshow(const std::string path, bool recursive, bool random);
static void SendSlideshowAction(int actionID);
static void OnPlaylistChanged();
static JSONRPC_STATUS GetPropertyValue(PlayerType player, const CStdString &property, CVariant &result);

0 comments on commit 5f87391

Please sign in to comment.