Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONRPC failed #72

Open
nx111 opened this issue Dec 26, 2012 · 3 comments
Open

JSONRPC failed #72

nx111 opened this issue Dec 26, 2012 · 3 comments

Comments

@nx111
Copy link

nx111 commented Dec 26, 2012

when use jsonrpc , Movie directory can't be enter. Log message in xbmc.log as:

19:37:10 T:2758789952 DEBUG: JSONRPC: Incoming request: {"jsonrpc":"2.0","id":"3722001967211620453","method":"Files.GetDirectory","params":{"directory":"/media/diske/Media/","media":"video","sort":{"ignorearticle":false,"method":"file","order":"ascending"},"properties":["mimetype","file"]}}
19:37:10 T:2758789952 DEBUG: JSONRPC: Calling files.getdirectory
19:37:10 T:2758789952 DEBUG: JSONRPC: Value does not match any of the enum values in type
19:37:10 T:2758789952 DEBUG: JSONRPC: Array element at index 0 does not match in type properties

@nx111
Copy link
Author

nx111 commented Dec 26, 2012

I patched xbmcremote and jsonrpclib,Now,I can enter a directory and watch movie,but can't get movie's totaltime and percentage yet.

xbmcremote.diff:

diff --git a/src/org/xbmc/android/remote/business/cm/InfoManager.java b/src/org/xbmc/android/remote/business/cm/InfoManager.java
index bf9d3dd..eb2c06c 100644
--- a/src/org/xbmc/android/remote/business/cm/InfoManager.java
+++ b/src/org/xbmc/android/remote/business/cm/InfoManager.java
@@ -84,7 +84,7 @@ public class InfoManager extends AbstractManager implements IInfoManager {
 public void getDirectory(DataResponse<ArrayList<FileLocation>> response,
            String path, Context context, int mediaType) {
        call(new Files.GetDirectory(path, MediaType.getName(mediaType),
-               getSort(ListModel.Sort.Method.FILE), FileItem.MIMETYPE,
+               getSort(ListModel.Sort.Method.FILE),
                FileItem.FILE),
                new ApiHandler<ArrayList<FileLocation>, FileItem>() {
                    @Override
diff --git a/src/org/xbmc/api/info/FileTypes.java b/src/org/xbmc/api/info/FileTypes.java
index 9b6a908..432e4dd 100644
--- a/src/org/xbmc/api/info/FileTypes.java
+++ b/src/org/xbmc/api/info/FileTypes.java
@@ -31,7 +31,7 @@ public class FileTypes {
    /**
     * Audio file extensions
     */
-   public final static String[] AUDIO = { "ac3", "flac", "m4a", "mp3", "mid", "ogg", "wav" };
+   public final static String[] AUDIO = { "ac3", "flac", "m4a", "mp3", "mid", "ogg", "wav", "rm", "wma" };

    /**
     * Playlist file extensions
@@ -41,7 +41,7 @@ public class FileTypes {
    /**
     * Video extensions
     */
-   public final static String[] VIDEO = { "avi", "flv", "mkv", "mov", "mp4", "mpg", "mpeg", "ts", "wmv", "vob" };
+   public final static String[] VIDEO = { "avi", "flv", "mkv", "mov", "mp4", "mpg", "mpeg", "ts", "wmv", "vob", "rmvb" };

    /**
     * Image extensions

jsonrpclib.patch:

diff --git a/src/org/xbmc/android/jsonrpc/api/AbstractModel.java b/src/org/xbmc/android/jsonrpc/api/AbstractModel.java
index f74a215..e74c0dd 100644
--- a/src/org/xbmc/android/jsonrpc/api/AbstractModel.java
+++ b/src/org/xbmc/android/jsonrpc/api/AbstractModel.java
@@ -89,7 +89,9 @@ public abstract class AbstractModel implements JsonSerializable, Parcelable {

    public static ArrayList<String> getStringArray(JsonNode node, String key) {
        if (node.has(key)) {
-           final ArrayNode a = (ArrayNode)node.get(key);
+           final ObjectMapper mapper = new ObjectMapper();
+           final ArrayNode a = mapper.createArrayNode();
+           a.add(node.get(key));
            final ArrayList<String> l = new ArrayList<String>(a.size());
            for (int i = 0; i < a.size(); i++) {
                l.add(a.get(i).getTextValue());
@@ -101,7 +103,9 @@ public abstract class AbstractModel implements JsonSerializable, Parcelable {

    public static ArrayList<Integer> getIntegerArray(JsonNode node, String key) {
        if (node.has(key)) {
-           final ArrayNode a = (ArrayNode)node.get(key);
+           final ObjectMapper mapper = new ObjectMapper();
+           final ArrayNode a = mapper.createArrayNode();
+           a.add(node.get(key));
            final ArrayList<Integer> l = new ArrayList<Integer>(a.size());
            for (int i = 0; i < a.size(); i++) {
                l.add(a.get(i).getIntValue());

@nx111
Copy link
Author

nx111 commented Dec 27, 2012

In addition,I patched it with the diff flowing, The problem what can't get movie's totaltime and percentage is fixed:

diff --git a/android-xbmcremote/src/org/xbmc/android/remote/business/NowPlayingPollerThread.java b/android-xbmcremote/src/org/xbmc/android/remote/business/NowPlayingPollerThread.java
index 462b6c5..1dc6b91 100644
--- a/android-xbmcremote/src/org/xbmc/android/remote/business/NowPlayingPollerThread.java
+++ b/android-xbmcremote/src/org/xbmc/android/remote/business/NowPlayingPollerThread.java
@@ -156,7 +156,7 @@ public class NowPlayingPollerThread extends Thread {
    private boolean updateNowPlayingCover(ICurrentlyPlaying currPlaying) {
        try {
            String downloadURI = currPlaying.getThumbnail();
-           if (downloadURI == null || downloadURI.length() == 0) {
+           if (downloadURI == null || downloadURI.length() == 0 || HostFactory.host == null) {
                mCover = null;
                String oldCoverPath = mCoverPath;
                mCoverPath = null;
@@ -181,7 +181,7 @@ public class NowPlayingPollerThread extends Thread {
    private boolean updateNowPlayingFanart(ICurrentlyPlaying currPlaying) {
        try {
            String downloadURI = currPlaying.getFanart();
-           if (downloadURI == null || downloadURI.length() == 0) {
+           if (downloadURI == null || downloadURI.length() == 0 || HostFactory.host == null) {
                mFanart = null;
                String oldFanartPath = mFanartPath;
                mFanartPath = null;
diff --git a/android-xbmcremote/src/org/xbmc/android/remote/business/cm/ControlManager.java b/android-xbmcremote/src/org/xbmc/android/remote/business/cm/ControlManager.java
index 825b229..93af406 100644
--- a/android-xbmcremote/src/org/xbmc/android/remote/business/cm/ControlManager.java
+++ b/android-xbmcremote/src/org/xbmc/android/remote/business/cm/ControlManager.java
@@ -164,7 +164,7 @@ public class ControlManager extends AbstractManager implements IControlManager {
                        GetActivePlayersResult result = results.get(results.size() - 1);
                        final int playerid = result.playerid;
                        callRaw(new Player.GetProperties(playerid, "time",
-                               "speed", "position", "percentage"),
+                               "speed", "position","totaltime", "percentage"),
                                new ApiHandler<Boolean, PlayerModel.PropertyValue>() {
                                    @Override
                                    public Boolean handleResponse(
@@ -251,7 +251,7 @@ public class ControlManager extends AbstractManager implements IControlManager {
                }

                public int getDuration() {
-                   return item.runtime;
+                   return parseTime(propertyValue.totaltime);
                }

                public String getArtist() {

@nx111
Copy link
Author

nx111 commented Dec 27, 2012

Crash with getAlbum when path.length<2. Patch for src/org/xbmc/android/remote/business/cm/ControlManager.java is here:

  @@ -290,6 +290,8 @@ public String getAlbum() {
                }
            }
            String[] path = item.file.replaceAll("\\\\", "/").split("/");
+          if (path.length<2)
+            return "";
           return path[path.length - 2];
         }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant