2012-12-31, 11:37
Hi all,
I'm making an internal website on my media server that controls all my xbmc endpoints in the house (a raspberry pi connected to the network in each room)
To do this, I'm coding it in PHP, and have been reading up on the V6 JSON-RPC api
All works fine, except the Player.Open function.Play function
My code:
A little explenation of the code.
I pass a episodeid to a page, it loads the details (this works)
retrieves the file location which is something like "nfs://***.***.***.***/export/Series/Futurama/Specials/Futurama - s00e02 - The Beast With A Billion Backs.avi"
and passes it to the api to play
The result I get is:
anyone who can help me?
Edit: made title more clear
I'm making an internal website on my media server that controls all my xbmc endpoints in the house (a raspberry pi connected to the network in each room)
To do this, I'm coding it in PHP, and have been reading up on the V6 JSON-RPC api
All works fine, except the Player.Open function.Play function
My code:
Code:
/* Play snippit */
public function play(){
$endpoint = new XbmcEndpoint(array( 'endpoint_address' => '***.***.***.***','endpoint_port' => '****','endpoint_user' => '****','endpoint_pass' => '****' ));
$episode = $endpoint->getEpisodeDetails(array('episodeid' => (int)(Request::getGetParameter('eid')), 'properties' => array('file')));
$result = $endpoint->play(array('item' => array('file' => $episode->file)));
}
/* XbmcEndpoint snippit */
public function getEpisodeDetails($params){
if(!$this->_validate()) return false;
$this->_deploy(array('jsonrpc' => '2.0', 'method' => 'VideoLibrary.GetEpisodeDetails', 'id' => '1', 'params' => $params));
return isset($this->result->result) && isset($this->result->result->episodedetails) ? $this->result->result->episodedetails : $this->result;
}
public function play($params){
if(!$this->_validate()) return false;
$this->_deploy(array('jsonrpc' => '2.0', 'method' => 'Player.Open', 'id' => '1', 'params' => $params));
return isset($this->result->result) && isset($this->result->result->episodes) ? $this->result->result->episodes : $this->result;
}
protected function _validate(){
if($this->endpoint_address !== null && $this->endpoint_port !== null) return true;
return false;
}
protected function _deploy($json){
$response = CURL::get(sprintf('http://%s:%s@%s:%s/%s%s',$this->endpoint_user,$this->endpoint_pass,$this->endpoint_address,$this->endpoint_port,$this->query,json_encode($json)), array(),'',$this->add_headers);
$this->result = json_decode($response['content']);
}
A little explenation of the code.
I pass a episodeid to a page, it loads the details (this works)
retrieves the file location which is something like "nfs://***.***.***.***/export/Series/Futurama/Specials/Futurama - s00e02 - The Beast With A Billion Backs.avi"
and passes it to the api to play
The result I get is:
Code:
stdClass Object
(
[error] => stdClass Object
(
[code] => -32700
[message] => Parse error.
)
[id] =>
[jsonrpc] => 2.0
)
anyone who can help me?
Edit: made title more clear