Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

jsonrpc: add "playercoreid" option to Player.Open

  • Loading branch information...
commit f41381dfb7ab7effd3fb27a197f1b42d94b502a2 1 parent cac270e
@Montellese Montellese authored
View
27 xbmc/interfaces/json-rpc/PlayerOperations.cpp
@@ -515,9 +515,11 @@ JSONRPC_STATUS CPlayerOperations::Rotate(const std::string &method, ITransportLa
JSONRPC_STATUS CPlayerOperations::Open(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant &parameterObject, CVariant &result)
{
- CVariant optionShuffled = parameterObject["options"]["shuffled"];
- CVariant optionRepeat = parameterObject["options"]["repeat"];
- CVariant optionResume = parameterObject["options"]["resume"];
+ CVariant options = parameterObject["options"];
+ CVariant optionShuffled = options["shuffled"];
+ CVariant optionRepeat = options["repeat"];
+ CVariant optionResume = options["resume"];
+ CVariant optionPlayer = options["playercoreid"];
if (parameterObject["item"].isObject() && parameterObject["item"].isMember("playlistid"))
{
@@ -624,6 +626,25 @@ JSONRPC_STATUS CPlayerOperations::Open(const std::string &method, ITransportLaye
}
else
{
+ // Handle the "playerid" option
+ if (!optionPlayer.isNull())
+ {
+ PLAYERCOREID playerId = (PLAYERCOREID)optionPlayer.asInteger();
+ // check if the there's actually a player with the given player ID
+ if (CPlayerCoreFactory::Get().GetPlayerConfig(playerId) == NULL)
+ return InvalidParams;
+
+ // check if the player can handle at least the first item in the list
+ VECPLAYERCORES possiblePlayers;
+ CPlayerCoreFactory::Get().GetPlayers(*list.Get(0).get(), possiblePlayers);
+ VECPLAYERCORES::const_iterator matchingPlayer = std::find(possiblePlayers.begin(), possiblePlayers.end(), playerId);
+ if (matchingPlayer == possiblePlayers.end())
+ return InvalidParams;
+
+ // set the next player to be used
+ g_application.m_eForcedNextPlayer = playerId;
+ }
+
// Handle "shuffled" option
if (optionShuffled.isBoolean())
list.SetProperty("shuffled", optionShuffled);
View
1  xbmc/interfaces/json-rpc/schema/methods.json
@@ -152,6 +152,7 @@
},
{ "name": "options", "type": "object", "additionalProperties": false,
"properties": {
+ "playercoreid": { "type": [ "null", { "type": "integer", "minimum": 1, "required": true } ], "default": null },
"shuffled": { "$ref": "Optional.Boolean" },
"repeat": { "type": [ "null", { "$ref": "Player.Repeat", "required": true } ], "default": null },
"resume": { "type": [
Please sign in to comment.
Something went wrong with that request. Please try again.