New feature - auto load next page (1 Viewer)

Rick164

MP Donator
  • Premium Supporter
  • January 7, 2006
    1,335
    1,005
    Home Country
    Netherlands Netherlands
    Hi,

    Been trying to add some additional functionality and started with auto load next page like there is on the actual Youtube website (i.e. infinite scroll).
    Have an basic working example already as it was quiet easy to hook it in OnItemSelected() and detect the next page translated text:

    http://pastebin.com/vHcviY7b

    However have an issue with using the correct DisplayVideos_NextPage() method as that returns an MP1 thread error about not running on the main thread so for testing I used an SendKey which is of course not doable for production builds.

    After fixing that would like to add an Settings UI entry to toggle this new feature however would first get some input from the developers if this feature is ok and where to improve :)
     
    Last edited:

    Ministerk

    Super User
  • Team MediaPortal
  • Super User
  • November 28, 2007
    970
    826
    Uppsala
    Home Country
    Sweden Sweden
    Great idea, but shouldn't it start loading earlier? If I'm on the last item then it's not that hard to press OK/enter, and you still need to pause your scrolling - otherwise you will end up at the top of the list again.

    You know how many items there are in the list and you know what index you are at (don't you?:p), why don't use this information and start loading new content when you are say 5-10 items from the last last in the list. Of course this would not work with the "{enter}" solution.

    EDIT: But I see one big problem with my suggestion: If I would like to enter or play, let us say, the 4th item from the bottom of the list I need to wait for the loading of next page before I could do that, then we would need to implement some kind of cancel functionality to the GUI2Util connector/backgroun process.
     
    Last edited:

    Rick164

    MP Donator
  • Premium Supporter
  • January 7, 2006
    1,335
    1,005
    Home Country
    Netherlands Netherlands
    That could work although there's the loading indicator and a slight UI delay when calling the next page so will test it out once I get the DisplayVideos_NextPage() method call working :)
    Can read the last Index label as I'm not sure if it's possible to read the total item count from the whole feed/category in advance as not every site provider might have that option.
     

    offbyone

    Development Group
  • Team MediaPortal
  • April 26, 2008
    3,989
    3,712
    Stuttgart
    Home Country
    Germany Germany
    You must not call UI updates from a background thread. Check the Gui2UtilConnector.cs :

    GUIWindowManager.SendThreadCallbackAndWait((p1, p2, o) => { ExecuteTaskResultHandler(); return 0; }, 0, 0, null);

    Maybe us the method without the Wait at the end ;)
     

    Rick164

    MP Donator
  • Premium Supporter
  • January 7, 2006
    1,335
    1,005
    Home Country
    Netherlands Netherlands
    Works like a charm now with the UI delegate, gonna try and see if it can be preloaded once the user is near the next page for true infinite scroll like @Ministerk suggested.
    Could also remove the loading facade for preloading but that would require some more changes or perhaps a separate NextPage method.
     

    Rick164

    MP Donator
  • Premium Supporter
  • January 7, 2006
    1,335
    1,005
    Home Country
    Netherlands Netherlands
    Added preloading when user is near the end (offset 10) with proper nextPage check this time, a few issues that might need looking at but not that familiar with OnlineVideos code so those might be handled already:

    - It loads NextPage() when difference between total items and current item index is 10 or lower however it will call it more than once if the user is scrolling fast enough or if the site takes a while, could add lock to prevent that or is this already handled by OnlineVideos NextPage method (check to see if loading for instance)?

    - Loading icon is displayed, either needs a new method or parameter to skip load animation but doesn't look that bad atm as you have an indication if something is loading in the background.

    - Jumps to new page item index but know where that one is coming from.

    Let me know what you guys think :)
    Current code (also in first post): http://pastebin.com/uzEfMhHr

    // Update

    Too bad OV isn't on GitHub as it would made it easier to do an pull request but oh well with Google Code closing it will be there soon enough ;) , for now added the full code to this post with an test .dll which is based on the current SVN.

    Had to change a few methods to allow for the item index to remain current and added a lock to the preload next page process just in case it does an extra load.
    Still not completed of course but good enough for testing I hope, gonna see if the pre-loading process can be a bit smoother as now there's an UI delay (when appending new results).
     

    Attachments

    • OV_MP1_PRELOADING_TEST_VERSION.zip
      400.7 KB
    • GUIOnlineVideos.cs.txt
      176.9 KB
    Last edited:

    Rick164

    MP Donator
  • Premium Supporter
  • January 7, 2006
    1,335
    1,005
    Home Country
    Netherlands Netherlands
    The preloading during navigation is a bit harder to do then expected because it appends new results and reloads the view which makes it act all jumpy (lag / reselecting the current index) so went with the load next page when on next page label instead which works alright.

    Attached diff patch and full source, kept the additional methods in there in case someone wants to try their hand on the preload during navigation :)
     

    Attachments

    • GUIOnlineVideos_AutoLoadNextPage_Patch001.txt
      5 KB
    • GUIOnlineVideos.cs.txt
      177.2 KB
    • OV_MP1_PRELOADING_TEST_VERSION2.zip
      400.7 KB
    Last edited:

    Ministerk

    Super User
  • Team MediaPortal
  • Super User
  • November 28, 2007
    970
    826
    Uppsala
    Home Country
    Sweden Sweden
    and added a lock to the preload next page process
    A note on this: you could use Gui2UtilConnector.IsBusy to check if something is executing in the background (and I think you should always check this before you start the task)..
     

    Users who are viewing this thread

    Top Bottom