Я использую libjson (https://github.com/cinemast/libjson-rpc-cpp) и API коди (ранее назывался XBMC для воспроизведения/паузы и остановки моей машины Kodi. Однако после того, как я остановил его, я не могу перезапустить его снова с помощью воспроизведения/паузы. Метод, который я использую: создать файл json, который jsonrpcstub может процесс для воспроизведения/паузы следующим образом:
[
{
"name" : "Player.PlayPause",
"description": "Pauses or unpause playback and returns the new state",
"params": [
{
"$ref": "Player.Id",
"name": "playerid",
"required": true
},
{
"$ref": "Global.Toggle",
"default": "toggle",
"name": "play"
}
],
"returns": {
"$ref": "Player.Speed"
},
"type": "method"
}
]
И затем я использую:
#include "xbmcremoteclient.h"
#include <jsonrpccpp/client/connectors/httpclient.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#ifndef WIN32
#include <termios.h>
#else
#include <conio.h>
#endif
#include <unistd.h>
#include <time.h>
#include <iostream>
using namespace jsonrpc;
using namespace std;
int main(int argc, char** argv) {
try {
HttpClient httpclient("http://user:[email protected]:8080/jsonrpc");
XbmcRemoteClient stub(httpclient);
stub.Player_PlayPause(0);
}
catch(JsonRpcException& e) {
cerr << e.what() << endl;
}
return 0;
}
сделать простой исполняемый файл для запуска этой команды. Однако это работает, когда я пытаюсь реализовать функцию goTo: http://kodi.wiki/view/JSON-RPC_API/v6#Player.GoTo
Я не могу с этим справиться. Я изменил файл json до этого:
[
{"jsonrpc": "2.0", "method": "Player.PlayPause", "params": { "playerid": 0 }, "id": 1},
{
"name": "Player.GoTo":,
"params": [
{
"name": "playerid",
"required": true
},
{
"name": "to",
"required": true,
"type": [
{
"enums": [
"previous",
"next"
],
"type": "string"
},
{
"description": "position in playlist"
}
]
}
],
"returns": {
"type": "string"
}
}
]
но я продолжаю получать синтаксическую ошибку при попытке запустить ее через jsonrpcstub:
Exception -32700 : JSON_PARSE_ERROR: The JSON-Object is not JSON-Valid: specification file contains syntax errors
Я бы предпочел просто запустить файл json, который я получаю при просмотре http://myKodiMachine.xy:8080/jsonrpc через jsonrpcstub, но это уже создает синтаксические ошибки. Кажется, его файл начинается так:
{
"description": "JSON-RPC API of XBMC",
"id": "http://xbmc.org/jsonrpc/ServiceDescription.json",
"methods": {
"Addons.ExecuteAddon": {
"description": "Executes the given addon with the given parameters (if possible)",
"params": [
{
"name": "addonid",
"required": true,
"type": "string"
},
{
"default": "",
"name": "params",
"type": [
{
"additionalProperties": {
"default": "",
"type": "string"
},
"type": "object"
},
{
"items": {
"type": "string"
},
"type": "array"
},
{
"description": "URL path (must start with / or ?",
"type": "string"
}
]
},
{
"default": false,
"name": "wait",
"type": "boolean"
}
],
"returns": {
"type": "string"
},
"type": "method"
},
"Addons.GetAddonDetails": {
"description": "Gets the details of a specific addon",
"params": [
{
"name": "addonid",
"required": true,
"type": "string"
},
{
"$ref": "Addon.Fields",
недействителен JSON по какой-то странной причине. Любые указания на возможность остановки и перезапуска списка воспроизведения в коди из Linux (таким образом или любым другим способом) будут считаться полезными. Мне это нужно, особенно потому, что я играю много потоков, и если я приостановлю их, они будут буферизованы (что не очень удобно), поэтому я предпочитаю останавливать/перезапускать их.
"name": "Player.GoTo":,
недействителен JSON - person Alvaro Montoro   schedule 09.01.2015