Skip to content

Commit

Permalink
jsonrpc: rename Player.Repeat to Player.SetRepeat with "repeat" param…
Browse files Browse the repository at this point in the history
…eter

In addition to "off", "one" and "all" the "repeat" parameter can also take
"cycle" as a value to cycle through the three repeat states.
  • Loading branch information
Montellese committed Oct 1, 2012
1 parent accafc5 commit ccb188c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
2 changes: 1 addition & 1 deletion xbmc/interfaces/json-rpc/JSONServiceDescription.cpp
Expand Up @@ -71,7 +71,7 @@ JsonRpcMethodMap CJSONServiceDescription::m_methodMaps[] = {
{ "Player.GoNext", CPlayerOperations::GoNext },
{ "Player.GoTo", CPlayerOperations::GoTo },
{ "Player.SetShuffle", CPlayerOperations::SetShuffle },
{ "Player.Repeat", CPlayerOperations::Repeat },
{ "Player.SetRepeat", CPlayerOperations::SetRepeat },
{ "Player.SetPartymode", CPlayerOperations::SetPartymode },

{ "Player.SetAudioStream", CPlayerOperations::SetAudioStream },
Expand Down
22 changes: 20 additions & 2 deletions xbmc/interfaces/json-rpc/PlayerOperations.cpp
Expand Up @@ -631,15 +631,33 @@ JSONRPC_STATUS CPlayerOperations::SetShuffle(const CStdString &method, ITranspor
return ACK;
}

JSONRPC_STATUS CPlayerOperations::Repeat(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
JSONRPC_STATUS CPlayerOperations::SetRepeat(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
switch (GetPlayer(parameterObject["playerid"]))
{
case Video:
case Audio:
CApplicationMessenger::Get().PlayListPlayerRepeat(GetPlaylist(GetPlayer(parameterObject["playerid"])), (REPEAT_STATE)ParseRepeatState(parameterObject["state"]));
{
REPEAT_STATE repeat = REPEAT_NONE;
int playlistid = GetPlaylist(GetPlayer(parameterObject["playerid"]));
if (parameterObject["repeat"].asString() == "cycle")
{
REPEAT_STATE repeatPrev = g_playlistPlayer.GetRepeat(playlistid);
repeat = repeatPrev;
if (repeatPrev == REPEAT_NONE)
repeat = REPEAT_ALL;
else if (repeatPrev == REPEAT_ALL)
repeat = REPEAT_ONE;
else
repeat = REPEAT_NONE;
}
else
repeat = (REPEAT_STATE)ParseRepeatState(parameterObject["repeat"]);

CApplicationMessenger::Get().PlayListPlayerRepeat(playlistid, repeat);
OnPlaylistChanged();
break;
}

case Picture:
default:
Expand Down
2 changes: 1 addition & 1 deletion xbmc/interfaces/json-rpc/PlayerOperations.h
Expand Up @@ -56,7 +56,7 @@ namespace JSONRPC
static JSONRPC_STATUS GoNext(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS GoTo(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result);
static JSONRPC_STATUS SetShuffle(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 SetRepeat(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);
Expand Down
9 changes: 7 additions & 2 deletions xbmc/interfaces/json-rpc/ServiceDescription.h
Expand Up @@ -1395,14 +1395,19 @@ namespace JSONRPC
"],"
"\"returns\": \"string\""
"}",
"\"Player.Repeat\": {"
"\"Player.SetRepeat\": {"
"\"type\": \"method\","
"\"description\": \"Set the repeat mode of the player\","
"\"transport\": \"Response\","
"\"permission\": \"ControlPlayback\","
"\"params\": ["
"{ \"name\": \"playerid\", \"$ref\": \"Player.Id\", \"required\": true },"
"{ \"name\": \"state\", \"$ref\": \"Player.Repeat\", \"required\": true }"
"{ \"name\": \"repeat\", \"type\": ["
"{ \"$ref\": \"Player.Repeat\", \"required\": true },"
"{ \"type\": \"string\", \"enum\": [ \"cycle\" ], \"required\": true }"
"],"
"\"required\": true"
"}"
"],"
"\"returns\": \"string\""
"}",
Expand Down
9 changes: 7 additions & 2 deletions xbmc/interfaces/json-rpc/methods.json
Expand Up @@ -328,14 +328,19 @@
],
"returns": "string"
},
"Player.Repeat": {
"Player.SetRepeat": {
"type": "method",
"description": "Set the repeat mode of the player",
"transport": "Response",
"permission": "ControlPlayback",
"params": [
{ "name": "playerid", "$ref": "Player.Id", "required": true },
{ "name": "state", "$ref": "Player.Repeat", "required": true }
{ "name": "repeat", "type": [
{ "$ref": "Player.Repeat", "required": true },
{ "type": "string", "enum": [ "cycle" ], "required": true }
],
"required": true
}
],
"returns": "string"
},
Expand Down

0 comments on commit ccb188c

Please sign in to comment.