views:

213

answers:

2

Please see: http://flx.me/h/0504/

Source: http://pastebin.com/bDh5k3Qd

jquery.preload-min.js: http://jquery.com/plugins/project/Preload

jquery.jplayer.min.js: http://www.happyworm.com/jquery/jplayer/0.2.4/developer-guide.htm

I'm using jquery.preload-min.js to preload images and to send a play trigger to jquery.jplayer.min.js to start playing a mp3 file.

This works great when viewing the page for the first time (or force reloading all content). However, when the image has already been cached, it doesn't use the preloading script and thus does not send the play trigger to jplayer.

How can I make it send a play trigger even when the image is cached?

Thank you in advance,

Dennis

A: 

1 Problem is - if image is cached, then onComplete not work, because requests to server are not sent.

2 As I understand from your code, you not need an onComplete callback for every image.. May be you can try onFinish event?

3 Best way to do this task is to write your own preloader :)

Vitaly Dyatlov
Hello Dyatlov,OnFinish does not change anything, since it doesn't load the script because the image is cached. If I had the skills I would had written a own preloader, but I'm very new to Jquery.Also, I've found this code: hxxp://github.com/peol/jquery.imgloaded/blob/master/ahpi.imgload.jsBut I can't seem to get it to work, I like to use the placeholder function its using at the moment so I've tried to use parts of it with no avail.Any other ideas?Thanks,Dennis
FLX
`.complete` *does* work with cached images. It is onLoad() that does not.
dclowd9901
+4  A: 

You can do something like this:

$("image_selector_here").each(function() {
  if(this.complete) $(this).load();
});

This triggers the load event for cached images (this.complete == true) where the browser isn't firing the .load() event itself.

Nick Craver
Make sure if you're waiting for all of the images to load before you're firing an event to give your loop a timeout. This took me way too long and cost me way too much hair to figure out.
dclowd9901
Is it possible that this doesn't work in IE7?
skybondsor