Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1348 from avdleeuw/xbmx-playeropen
Browse files Browse the repository at this point in the history
XBMC - Add binding option to use 'Player.open' RPC call.
  • Loading branch information
teichsta committed Aug 17, 2014
2 parents db513aa + b9b6b34 commit 9db6c0c
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ protected void internalReceiveCommand(String itemName, Command command) {
// TODO: handle other commands
if (property.equals("Player.PlayPause"))
connector.playerPlayPause();
if (property.equals("Player.Open"))
connector.playerOpen(command.toString());
if (property.equals("Player.Stop"))
connector.playerStop();
if (property.equals("GUI.ShowNotification"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.openhab.binding.xbmc.rpc.calls.JSONRPCPing;
import org.openhab.binding.xbmc.rpc.calls.PlayerGetActivePlayers;
import org.openhab.binding.xbmc.rpc.calls.PlayerGetItem;
import org.openhab.binding.xbmc.rpc.calls.PlayerOpen;
import org.openhab.binding.xbmc.rpc.calls.PlayerPlayPause;
import org.openhab.binding.xbmc.rpc.calls.PlayerStop;
import org.openhab.binding.xbmc.rpc.calls.SystemShutdown;
Expand Down Expand Up @@ -312,6 +313,12 @@ public void systemShutdown() {
shutdown.execute();
}

public void playerOpen(String file) {
final PlayerOpen playeropen = new PlayerOpen(client, httpUri);
playeropen.setFile(file);
playeropen.execute();
}

private void processPlayerStateChanged(String method, Map<String, Object> json) {
if ("Player.OnPlay".equals(method)) {
// get the player id and make a new request for the media details
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Copyright (c) 2010-2014, openHAB.org and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.openhab.binding.xbmc.rpc.calls;

import java.util.HashMap;
import java.util.Map;

import org.openhab.binding.xbmc.rpc.RpcCall;

import com.ning.http.client.AsyncHttpClient;

/**
* Player.Open RPC
*
* @author Ard van der Leeuw
* @since 1.6.0
*/
public class PlayerOpen extends RpcCall {

private String file;

public PlayerOpen(AsyncHttpClient client, String uri) {
super(client, uri);
}

public void setFile(String file) {
this.file = file;
}

@Override
protected String getName() {
return "Player.Open";
}

@Override
protected Map<String, Object> getParams() {
Map<String, Object> params = new HashMap<String, Object>();
Map<String, Object> item = new HashMap<String, Object>();

item.put("file", file);
params.put("item", item);
return params;
}

@Override
protected void processResponse(Map<String, Object> response) {
}
}

0 comments on commit 9db6c0c

Please sign in to comment.