preload a picture ?

  • Hi,

    Is it possible to preload the pictures my tour will use ?

    My problem is, there's too much latency between the moment you click on a "showpic" hotspot, and the moment the picture flies in. At least on the first click. Because the second time you call the same picture, it appears instantly.

    I've checked in the documentation and i didn't see a variable about it, on a hotspot.

    Thanks. *smile*
    Steph.

  • You can use preload to load it before the pano loads, or outside of krpano by loading the images in html with display:none.

    I wish there was a good krpano method to declare an array of items to begin downloading after a tour is loaded.
    Probably you could make an action run onxmlcomplete to cycle on this array of images by changing a plugins url and with scale=0 and cycling to the next when onloaded.

    :)

  • You can use preload to load it before the pano loads, or outside of krpano by loading the images in html with display:none.:)


    Thanks Sachagriffin. The html solution seems to be good. The thing is how and where should i write that ? There's no example about a loading section in the html. Has it ever been tested ?

    Quote

    Probably you could make an action run onxmlcomplete to cycle on this array of images by changing a plugins url and with scale=0 and cycling to the next when onloaded.


    Mi pictures ,in this case, aren't acting as plugin. It's the "fly in and out" action. That means the picture is called only once you click on the hotspot, so there's no code assigned to a picture in particular. It's a general action code. I've tried to add a preload to the hotspot but it's not that.

    are you saving the pics for web through photoshop? just wanted to make sure the file sizes were not to large.


    My average picture size is 450Ko. I think it's correct, isn't it ?

    Thanks for your help. *wink*
    Steph.

  • Hi,

    instead of loading the image dynamically you can load it already at startup with visible="false" and then show it only when needed,

    or if you don't want to change the code just add:

    Code
    <plugin name="cacheimage1" url="yourimage.jpg" visible="false" />

    the image will be loaded but not shown, and when the image will be loaded a second time from an other element, then it is already there in the cache (in Flash it would be in krpano's own cache and in HTML probably in the browser cache),

    best regards,
    Klaus

  • Thanks Klaus and Sachagriffin. It works. It tooks only 2s to display the picture.;-)

    Is there a way to write a code to load several pictures. For example, i've got seven pictures in my tour, do i have to write a line or a plugin for each one ?

    Thanks again. *smile*
    Steph

  • Is there a priority for plugins being visible or not?
    Say you have 5 MB of photos in plugins visible false, and you load your tour, do all your visible plugins download first?
    So that your interface shows immediately, and your visible false plugins download last.

    sasha for 2 years i built everything into 1 xml with includes to load secondary xml files. that is a bad way to do things. stay away from includes each one is another request back to your server. having them all in 1 file is not as oranized but it does load alot faster. to your main question though. what i also started doing is using a start.xml file. this file has everything in the tour i want to load first. tour skin, actions, styles, global plugins. then onloadcomplete="loadpano(firstscene.xml,null,merge,blend(2))" which loads the first set of tiles. you could use a start.xml to load what you want first then put the photo plugins on the firstscene.xml and they will alway load silently while the user starts to move around after the rest is loaded.

    if you use this method and buy Jaydee's swfaddress plugin you do not need the onloadcomplete. the swf loads the first pano and you can link to any scene inside your tour as the entry point and the tour skin, action and such will always load. make it so if you were in a hotel and wanted to drop someone right in the pool room you can and the entire interface is the same as if you started from what normally would have to be the first scene.

    hope that makes sense.

  • Is there a way to write a code to load several pictures. For example, i've got seven pictures in my tour, do i have to write a line or a plugin for each one ?

    yes esys you would need 1 of these for each image. i am not aware of a way to chain preloaded images all at once. maybe via javascript but this amount of code is so small you could have 100 of them and the xml will not grow much larger. the time to preload the iamges them selves would be worse. 7 wont be much of an issue.

    Code
    <plugin name="cacheimage1" url="yourimage.jpg" visible="false" />
  • Thanks VN.

    You're right, it's not that bad to write seven short plugins. The thing is i'm not enough confident, so far, with the %1, that means i've already written a lot of lines in my code, because of the actions i've created. That's why i'm looking for the shortest way to write this.

    Thanks everybody, it works perfectly. *thumbup*

    Steph.

  • Ah, great advice. Thanks!

    sasha for 2 years i built everything into 1 xml with includes to load secondary xml files. that is a bad way to do things. stay away from includes each one is another request back to your server. having them all in 1 file is not as oranized but it does load alot faster. to your main question though. what i also started doing is using a start.xml file. this file has everything in the tour i want to load first. tour skin, actions, styles, global plugins. then onloadcomplete="loadpano(firstscene.xml,null,merge,blend(2))" which loads the first set of tiles. you could use a start.xml to load what you want first then put the photo plugins on the firstscene.xml and they will alway load silently while the user starts to move around after the rest is loaded.

    if you use this method and buy Jaydee's swfaddress plugin you do not need the onloadcomplete. the swf loads the first pano and you can link to any scene inside your tour as the entry point and the tour skin, action and such will always load. make it so if you were in a hotel and wanted to drop someone right in the pool room you can and the entire interface is the same as if you started from what normally would have to be the first scene.

    hope that makes sense.

Participate now!

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