Playing media accessed via JSON-RPC - help!
#1
Hi,

Semi-noob here.

I'm experimenting with the JSON-RPC at the moment. I can retrieve everything fine, dump records as list items and display them... All good, so much better than the HTTP-API :-)

However, I cannot get the onclick behaviour (i.e. play the damn movie) to work. The closest I've got is below - see the commented out movieListItem.setpath. Using the xbmc.player method seems to just play the first list item automatically.

Anyone able to help?

Cheers!
theDeadMan.

Code:
movieRecords = simplejson.loads(xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetRecentlyAddedMovies","params":{"end":5,"fields": ["year","runtime"]},"id":1}'))
        movieList = movieRecords["result"]["movies"]
        for movie in movieList:            
            movieListItem = xbmcgui.ListItem()
            movieListItem.setLabel(movie["label"])
            movieListItem.setLabel2(str(movie["year"])+" • "+str(movie["runtime"])+" minutes")
            #movieListItem.setPath(xbmc.Player().play(movie["file"]))
            movieListItem.setThumbnailImage(movie["thumbnail"])
            self.xbmcListItems.append(movieListItem)
Reply
#2
XBMC.Play(movieid=X) as jsonrpc method
If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

Image

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
Reply
#3
Thanks Topfs2,

JSON-RPC method you suggested works, but essentially ends up causing the same problem. As soon as the script populates the list, XBMC still tries to play the first movie (as set by the listitem.setpath) without any click / other input from me.

Is this the expected behavior of listItem.setPath? If so, is there another method of setting the onclick behaviour of a list item from Python?

Cheers,
theDeadman.
Reply
#4
Anybody?

I've checked as many scripts out there as I can find but I'm brick-walling it now. The closest is the recent content script, but that uses setProperty to change the values of predefined / static list items which kinda limits the sorts of things I want to explore...

Here's a simple example of what I'm working with to get the 5 most recent movies using JSON-RPC:

Code:
import xbmc
import xbmcgui
import re
import simplejson

class Main:
    thisWindow = xbmcgui.Window(xbmcgui.getCurrentWindowId())

    def __init__(self):
        self.getParams()
        self.fetchDB()
        self.returnListContent()
    
    def getParams(self):
        params = dict(arg.split("=") for arg in sys.argv[1].split("&"))
        self.controlID = int(params.get("controlid", ""))
    
    def fetchDB(self):
        self.xbmcListItems = []
        
        movieRecords = simplejson.loads(xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetRecentlyAddedMovies","params":{"end":5,"fields": ["year","runtime"]},"id":1}'))
        movieList = movieRecords["result"]["movies"]
        for movie in movieList:            
            movieListItem = xbmcgui.ListItem()
            movieListItem.setLabel(movie["label"])
            movieListItem.setLabel2(str(movie["year"])+" • "+str(movie["runtime"])+" minutes")
            :no:movieListItem.setPath(xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "XBMC.Play","params":{"movieid":5},"id":1}'))
            movieListItem.setThumbnailImage(movie["thumbnail"])
            self.xbmcListItems.append(movieListItem)
    
    def returnListContent(self):
        self.thisWindow.getControl(self.controlID).addItems(self.xbmcListItems)
        
if (__name__ == "__main__"):
    Main()

The setpath bit is causing the headache. Running the script automatically tries to start movieid 5, which fails. Upon which clicking any of the list items returns sweet FA.

Any suggestions?
Reply
#5
Don't want to be so persistent but this is really holding me up. Do I need to raise this on TRAC?

If i'm doing something fundamentally wrong, it would be useful to know Wink
Reply
#6
Opened ticket on TRAC: http://trac.xbmc.org/ticket/11294
Reply

Logout Mark Read Team Forum Stats Members Help
Playing media accessed via JSON-RPC - help!0