Skip to content
Browse files

jsonrpc: add Player.SetPartymode

  • Loading branch information...
1 parent 37ed4d9 commit 95c4719ad841216bf1adf13497dd2e1a616ea115 @Montellese committed Sep 30, 2012
View
11 xbmc/PartyModeManager.cpp
@@ -550,6 +550,17 @@ int CPartyModeManager::GetRandomSongs()
return m_iRandomSongs;
}
+PartyModeContext CPartyModeManager::GetType() const
+{
+ if (!IsEnabled())
+ return PARTYMODECONTEXT_UNKNOWN;
+
+ if (m_bIsVideo)
+ return PARTYMODECONTEXT_VIDEO;
+
+ return PARTYMODECONTEXT_MUSIC;
+}
+
void CPartyModeManager::ClearState()
{
m_iLastUserSong = -1;
View
1 xbmc/PartyModeManager.h
@@ -56,6 +56,7 @@ class CPartyModeManager
int GetMatchingSongsLeft();
int GetRelaxedSongs();
int GetRandomSongs();
+ PartyModeContext GetType() const;
private:
void Process();
View
1 xbmc/interfaces/json-rpc/JSONServiceDescription.cpp
@@ -80,6 +80,7 @@ JsonRpcMethodMap CJSONServiceDescription::m_methodMaps[] = {
{ "Player.Shuffle", CPlayerOperations::Shuffle },
{ "Player.UnShuffle", CPlayerOperations::UnShuffle },
{ "Player.Repeat", CPlayerOperations::Repeat },
+ { "Player.SetPartymode", CPlayerOperations::SetPartymode },
{ "Player.SetAudioStream", CPlayerOperations::SetAudioStream },
{ "Player.SetSubtitle", CPlayerOperations::SetSubtitle },
View
50 xbmc/interfaces/json-rpc/PlayerOperations.cpp
@@ -681,6 +681,56 @@ JSONRPC_STATUS CPlayerOperations::Repeat(const CStdString &method, ITransportLay
return ACK;
}
+JSONRPC_STATUS CPlayerOperations::SetPartymode(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
+{
+ PlayerType player = GetPlayer(parameterObject["playerid"]);
+ switch (player)
+ {
+ case Video:
+ case Audio:
+ {
+ bool change = false;
+ PartyModeContext context = PARTYMODECONTEXT_UNKNOWN;
+ std::string strContext;
+ if (player == Video)
+ {
+ context = PARTYMODECONTEXT_VIDEO;
+ strContext = "video";
+ }
+ else if (player == Audio)
+ {
+ context = PARTYMODECONTEXT_MUSIC;
+ strContext = "music";
+ }
+
+ bool toggle = parameterObject["partymode"].isString();
+ if (g_partyModeManager.IsEnabled())
+ {
+ if (g_partyModeManager.GetType() != context)
+ return InvalidParams;
+
+ if (toggle || parameterObject["partymode"].asBoolean() == false)
+ change = true;
+ }
+ else
+ {
+ if (toggle || parameterObject["partymode"].asBoolean() == true)
+ change = true;
+ }
+
+ if (change)
+ CApplicationMessenger::Get().ExecBuiltIn("playercontrol(partymode(" + strContext + "))");
+ break;
+ }
+
+ case Picture:
+ default:
+ return FailedToExecute;
+ }
+
+ return ACK;
+}
+
JSONRPC_STATUS CPlayerOperations::SetAudioStream(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
switch (GetPlayer(parameterObject["playerid"]))
View
1 xbmc/interfaces/json-rpc/PlayerOperations.h
@@ -64,6 +64,7 @@ namespace JSONRPC
static JSONRPC_STATUS Shuffle(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS UnShuffle(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS Repeat(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
+ static JSONRPC_STATUS SetPartymode(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS SetAudioStream(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS SetSubtitle(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
View
11 xbmc/interfaces/json-rpc/ServiceDescription.h
@@ -1457,6 +1457,17 @@ namespace JSONRPC
"],"
"\"returns\": \"string\""
"}",
+ "\"Player.SetPartymode\": {"
+ "\"type\": \"method\","
+ "\"description\": \"Turn partymode on or off\","
+ "\"transport\": \"Response\","
+ "\"permission\": \"ControlPlayback\","
+ "\"params\": ["
+ "{ \"name\": \"playerid\", \"$ref\": \"Player.Id\", \"required\": true },"
+ "{ \"name\": \"partymode\", \"$ref\": \"Global.Toggle\", \"required\": true }"
+ "],"
+ "\"returns\": \"string\""
+ "}",
"\"Player.SetAudioStream\": {"
"\"type\": \"method\","
"\"description\": \"Set the audio stream played by the player\","
View
11 xbmc/interfaces/json-rpc/methods.json
@@ -393,6 +393,17 @@
],
"returns": "string"
},
+ "Player.SetPartymode": {
+ "type": "method",
+ "description": "Turn partymode on or off",
+ "transport": "Response",
+ "permission": "ControlPlayback",
+ "params": [
+ { "name": "playerid", "$ref": "Player.Id", "required": true },
+ { "name": "partymode", "$ref": "Global.Toggle", "required": true }
+ ],
+ "returns": "string"
+ },
"Player.SetAudioStream": {
"type": "method",
"description": "Set the audio stream played by the player",

0 comments on commit 95c4719

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