How to preload panorama source images?

  • I've seen mentions of this before and I have a feeling I'm just being a bit slow...

    But how do I code the XML to get a set of cubefaces for a pano preloaded when I open a different one?
    For example, pano 'A' has hotspot links to pano 'B' and pano 'C'. How do I get the cubefaces for panos 'B' and 'C' to be preloaded when someone visits pano 'A'?

    k

  • Hi,

    there is no direct preloading support in krpano at the moment,

    the only thing you could do at the moment is to 'preload' the image manually ,
    either via javascript or via krpano actions,

    e.g. like this - load an image as hidden plugin:

    best regards,
    Klaus

  • the only thing you could do at the moment is to 'preload' the image manually ,
    either via javascript or via krpano actions

    Thanks for the info Klaus, and especially for the suggested example. I'm afraid my stupidity seems to have caught up with me again - I implemented this like so:

    The images I need to preload are in a folder called "five" and the images are named "five_l.jpg", etc.
    The Status bar (bottom of the browser window) in Firefox shows "Transferring data from http://www.panoramaphotographer.com" when I load the page/XML with this code. However, this never changes, and Activity Monitor shows no significant network activity. When I click the hotspot link to go to the next pano, the one that should be preloaded, it loads at the normal un-cached speed. When I then go back and try again it loads fast, because I've now been there and it *is* cached.

    What's the simplest possible way to code this? I don't need to worry about tracing to see if it is done, I just want it to preload in the hope that the visitor waits long enough and ends up with a smoother, quicker step to the next pano.

    Thanks!

    Keith

  • Hi thatkeith,

    Perhaps a path issue...The ones on your example are, by default, relative to first loaded XML path... Just an idea, try adding %SWFPATH% placeholder in your paths...

    Code
    <action name="preloadpano1">
      preloadimage(pano1_l, %SWFPATH%/five/five_l.jpg);
      preloadimage(pano1_f, %SWFPATH%/five/five_f.jpg);
      preloadimage(pano1_r, %SWFPATH%/five/five_r.jpg);
      preloadimage(pano1_b, %SWFPATH%/five/five_b.jpg);
      preloadimage(pano1_u, %SWFPATH%/five/five_u.jpg);
      preloadimage(pano1_d, %SWFPATH%/five/five_d.jpg);
    </action>

    Hope this can help...

    SAlut.

  • Perhaps a path issue...

    Hi Michel,

    Thanks for the help. Unfortunately it didn't make any difference. All the XML files are at the same level, and so is the krpano.swf file. I've also tried dumping the images out into the same directory as everything else and altering the paths everywhere to match. But no, it still loads from scratch when I first try clicking the hotspot to the second place, then faster when I navigate back and try again.

    The images referred to in both the preloader trick and the second XML file are definitely the same...

    Erm... are there any other ways to try forcing a preload? Or anything more I can try with this code? I don't need to monitor for when it is done or any sophisticated stuff like that, just attempt to get something loaded before the user gets around to clicking and having to wait.

    k

  • Hi keith,

    The krpano debugger returns:

    Code
    INFO: krpano 1.0.8 beta 6 (build 2009027)
    INFO: Flashplayer WIN 10,0,42,34 PlugIn
    INFO: registered to: Keith Martin
    INFO: unknown action command: preloadpano1
    INFO: unknown action command: preloadpano1


    So, the action does not execute... Do not know why...
    Try action(preloadpano1); instead of preloadpano1();

    Code
    <events onloadcomplete="action(preloadpano1);" />

    SAlut.

  • Hi keith,

    I have tried the code with krpano 1.0.8 beta9 and it work....
    I think the problem is the version your are using (krpano 1.0.8 beta 6)
    Direct call to an action exist only since krpano 1.0.8 beta 8:

    user defined actions <action> can now be called "direct"
    e.g. instead of:

    Code
    action(actionname, parameters...);


    now also just:

    Code
    actionname(parameters...);


    is possible

    SAlut.

  • Thanks Michel, you've certainly spotted something I should have fixed before now! I've upgraded krpano.swf to b9.

    I'm still a bit in the dark about what's happening; the preloading doesn't seem to be working even now, although I admit I'm probably beginning to confuse myself through code tweaks back and forth.

    The XML files are all at the same level, and I've done the same with the images for the test. (And the XML file that uses those images. *smile* But it seems to load as slowly as others when I empty the browser cache and start fresh, then quickly when I navigate back and try again without emptying the cache.

    Would it be possible to simplify the original script? Does it need all the parts that were suggested? Or is there a bit of the documentation I should read to understand this better?

    (Sorry!)

    k

  • Hi Keith,

    Your code is working properly now *wink* ... The preloadpano1() action works correctly and your cube face images are cached as expected...
    I think you are confused because Firefox displays that it makes a connection and transfer some data... like if it is loading ALL the files needed for the next pano... BUT IT IS NOT LOADING ALL THE FILES... IT ONLY LOADS THE XML FILE ( 5inside-gates.xml ) THAT IT IS NOT CACHED YET...The cube face are already cached, so, they do not are reloaded and the pano is showed more quickly *smile* ...

    (edited)One note: you are calling the action twice inside your 7reception.xml....
    on the onstart :

    Code
    <krpano version="1.0.8" onstart="set(doturnview,no); preloadpano1();.....


    and on the onloadcomplete :

    Code
    <events onloadcomplete="preloadpano1();" />


    That is not a real problem.. only that it is executed 2 times...

    SAlut...

    Edited once, last by michel (February 10, 2010 at 3:43 AM).

  • Your code is working properly now *wink* ... The preloadpano1() action works correctly and your cube face images are cached as expected...

    Michel, you're right! Thanks, I think I managed to juggle things back to a working state without realising! Too much reloading must have fried my perceptions...

    Okay, I'm beginning to get this. Great stuff. And thanks! *smile*

    k

    I fixed the double call too. Heh.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!