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

  • SEARCH
  • Home
  • 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 8781879
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:25:23+00:00 2026-06-13T20:25:23+00:00

I’m using [youtube api ][1] to get to know when a video is fully

  • 0

I’m using [youtube api ][1] to get to know when a video is fully buffered player.getVideoLoadedFraction()

when the fraction is 1, the video is fully buffered, but I have to poll this function to check whether it is 1 and then get the time, like:

setInterval(display_fraction,1);

since a video could be tens of minutes.

Will this polling creates a heavy load on the browser/client and thus affect the video streaming? are there any other better polling methods or ways to detect when youtube finishes buffering?

BTW, the link for youtube api is:
https://developers.google.com/youtube/flash_api_reference#Playback_controls

  • 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-13T20:25:24+00:00Added an answer on June 13, 2026 at 8:25 pm

    Humans start perceiving time intervals somewhere between a 20th and a 10th of a second, so trying to poll with a value of 1ms is neither necessary nor desireable (any modern browser will round that up to 5ms or 10ms anyway). Values like 50 or 100 would be more appropriate.

    I would also strongly recommend using a chained series of setTimeout calls rather than a setInterval call, something like this:

    function onVideoReady(callback) {
    
        // Do first check as soon as the JavaScript engine is available to do it
        setTimeout(checkVideoReady, 0);
    
        // Our check function
        function checkVideoReady() {
            if (videoIsReady) {
                // The video is ready, notify calling code
                callback();
            }
            else {
                // Not ready yet, wait a 10th of a second
                setTimeout(checkVideoReady, 100);
            }
        }
    }
    

    …which you then use like this:

    onVideoReady(function() {
        // The video is ready, do something
    });
    

    The reasons I advocate a chained series of setTimeout instead of setInterval are:

    1. You can change the delay easily from iteration to iteration. For instance in the above, I fire the check as soon as possible the first time, then then after 100ms each subsequent time. You can do more complex things with timing than that, the flexibility is there.

    2. It’s much, much harder to inadvertently end up with more than one running, since code has to explicitly trigger the next loop.

    3. setInterval varies amongst browsers about whether it measure the interface from the start of the last call or the end of it. If you use a pattern like the above, you’re always sure it’s from the end of the last check.

    4. If your code is still running when the next interval is meant to occur, it just gets skipped. This can cause gaps (e.g., if you’re doing something every 100ms and your previous loop takes 102ms to complete, the next one doesn’t start as soon as possible, it waits the remaining 98ms), at least on some browsers.

    But it’s up to you, of course, the above can be done just as easily with setInterval and clearInterval calls as with a chain of setTimeout calls.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
I have thousands of HTML files to process using Groovy/Java and I need to
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but

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.