/    Sign up×
Community /Pin to ProfileBookmark

Script to add images as they are loaded

I’ve been researching the ability to dynamically build an array of images that would display in a javascript player. The problem is in every solution I have found it isn’t dealing with the issue that new images are getting loaded every 1-4 seconds. Maybe I’m missing something. Here is the complete scenario:

  • 1.

    Let’s say I have a security camera mounted somewhere. I cannot stream video so the camera sending .jpgs every 10 milliseconds to a folder on my web server. Standard naming convention img_1.jpg, img_2.jpg and so on.

  • 2.

    The user wants to view the images as they come in. We have a simple javascript player that cycles through the images and allows the user to pause and reverse. It’s very much like the view found here: [url]http://umbra.nascom.nasa.gov/eit/cme/19981015/cme_19981015_js.html[/url]

  • The problem is that I don’t want to refresh the page but the script builds a static array of images. I wrote a script on the server side that keeps track of the images being added to the folder. But html page is still static. Is there a way that the images the page is looking for can be dynamically updated? I’m sure I’m missing something here so your help and guidance is very much appreciated.

    devyon122

    to post a comment
    JavaScript

    3 Comments(s)

    Copy linkTweet thisAlerts:
    @tirnaJul 21.2010 — If you don't want the page to refresh when the images are updated, then 1 option you have is to use AJAX to periodically send, using javascript's setInterval(), a request to a server side script to return an updated list of image file names back to the browser. On each request, you would have to first abort the previous request if it was not completed for some reason, to avoid clashes.
    Copy linkTweet thisAlerts:
    @devyon122authorJul 21.2010 — Thanks I will research using setInterval(), thanks
    Copy linkTweet thisAlerts:
    @tirnaJul 22.2010 — no problem ? - but I would suggest looking into getting Ajax to do what you need first, if that is the route you end up taking.

    Setting a time period using setInterval() for the jajax requests is probably the last thing you would do.

    Anyway, just some food for thought.
    ×

    Success!

    Help @devyon122 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.19,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...