Updating displayed lists
#1
Hello All,

I am one of the developers of XBMB3C (soon to be renamed Smile ) - an AddOn that allows you to use MediaBrowser as the XBMC database.

The MediaBrowser JSON data gets quite heavy when someone has, say, 1000 movies.

What I would like to do is display the first 100, then background process the remaining 900 and update the list.

The PyDocs for both AddDirectoryItem and EndOfDirectory *hint* at the ability to do this, but I can't get it to work.

If I try to do:

Code:
adddirectoryitem(foo)
endofdirectory
xbmc.sleep(5000) #simulate crunching stuff
adddirectoryitem(bar)
endofdirectory(updateListing=True)

The directory is displayed, and the xbmc.sleep does not block the user, however the second end of directory does nothing.

If I try to do:
Code:
if firstrun
  adddirectoryitem(foo)
  endofdirectory
  firstrun=false
  container.refresh
else
  xbmc.sleep(5000) #simulate crunching stuff
  adddirectoryitem(bar)
  endofdirectory(updateListing=True)
then the xbmc.sleep blocks the user during the second pass, but the directory DOES update.

What is the right way to do this (if any?)?

xnappo
Reply
#2
So these are the comments I would like clarification on:

Code:
addDirectoryItems(...)
addDirectoryItems(handle, items [,totalItems])--Callback function to pass directory contents back to XBMC as a list.
  ...
   You may call this more than once to add items in chunks

What is the use case of adding in chunks? Again I want to add some data to get the user up and running and background load the rest of the list.

Code:
endOfDirectory(...)
...
updateListing : [opt] bool - True=this folder should update the current listing/False=Folder is a subfolder(Default).

I can get updateListing to work - but not to do anything useful. What is the use-case it is intended for?

Thanks,
xnappo
Reply
#3
You can't do this currently. 'totalItems' is for giving feedback to progress bar so it knows how many you intend to add. 'updateListing' is for overwriting history such that going 'up' will not take you back to the previous listing, but the one before.
Reply
#4
Okay - thanks a lot for the response.
Reply
#5
It is possible to do this, but it is a bit ugly. You have to cache the previous items in any case. If you want to load the content in the background you will have to use a script.

Just list the first 100 entries as you would normally and add a "show more" entry at the end:
Code:
addDirectoryItems(1-100)
addDirectoryItem(show_more)

xbmcplugin.endOfDirectory(int(sys.argv[1]))

If you add more entries:

Code:
i = 100 #index of the last entry (in that case 100)

addDirectoryItems(0-100) #cached items
addDirectoryItems(101-200) #new items
addDirectoryItem(show_more)

wnd = xbmcgui.Window(xbmcgui.getCurrentWindowId())
wnd.getControl(wnd.getFocusId()).selectItem(i) #this selects the last entry of the last list

xbmcplugin.endOfDirectory(int(sys.argv[1]), updateListing=True) #this will replace the old list

You could replace the "show more" entry with a script, which checks if the last entry is selected.


Not ideal but it is something.
Reply
#6
Thanks! Gives me something to play with..
Reply

Logout Mark Read Team Forum Stats Members Help
Updating displayed lists0