Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9258861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:30:50+00:00 2026-06-18T12:30:50+00:00

I want this to happen in a infinite loop, that I can exit at

  • 0

I want this to happen in a infinite loop, that I can exit at some point, but thats not the point..

So I have a list of dom elements with either video, or image.

I first look, is this an image, if so:

Display the image for X seconds
Then continue

If its a video

I play the video, and on the onend event, I continue

Now I start the proces again, and look again ,video or image? So the flow goes on forever, when it reaches the end, it just goes to the first element.

Now doing all that is not the problem, but putting that inside a loop and pausing for X amount of time, or till the video is done playing, there im stuck.

This is what it would look like:

func = () ->
console.log "Loop started, now wait X seconds"

delay 3000, ->
    console.log "OK, I waited 3 seconds, now lets go on"

delay 1000, ->
    console.log "Cool, I waited another second, now lets go on"
console.log "Ok, nothing to do, lets start again.."
func()

So this loop should in this case restart every 4 seconds
Any ideas for methods that I can look at?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:30:51+00:00Added an answer on June 18, 2026 at 12:30 pm

    I think your code should be structured like this:

    status = 'nothing'
    
    function loop() {
        if status == 'nothing'
    
            if next item is image
                show image
                status = 'image'
                countdown = 1000 // time to display the image
    
            if next item is video
                play video
                videoIsEnded = false
                status = 'video'
                video.onend = function { videoIsEnded = true }
    
        if status == 'image'
            if countdown-- < 0
                hide image
                status = 'nothing'
    
        if status == 'video'
            if videoIsEnded
                hide video
                status = 'nothing'
    }
    
    setInterval(loop, 1000) // check the status every second
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want this for some conditional compilation code that will run in all IE's
I want this to be on top... how can I do this and not
I only want this function to run if .toolbar li does not have the
I want this to happen if it contains Thing (Thing 1, Thing 2) but
I want this highchart - http://jsfiddle.net/zPDca/ inside a popup. But if i decrease its
I want this text all on one line, not spaced on two sepearate lines.
$(#IMAGE1).animate({left: +=1050px, queue: false}, slow, function() { // Want this to happen when the
I have div with no fixed with. I want this div position in the
I have an Image (which looks like a round loading circle) that I want
I am using the wordpress function update_user_meta($user_ID, 'meta_key', $meta); I want this happen only

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.