Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2012
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    poll in javascript

    I'm using youtube api 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/youtub...yback_controls

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,640
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Instead of testing every millisecond why not test just a few times a second - make the 1 into 250 to test four times a second or 500 to test twice a second.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,969
    Thanks
    56
    Thanked 557 Times in 554 Posts
    there is the onStateChange event listener which "fires whenever the player's state changes" - if I understand correctly I'm guessing that you would be looking for 5 (video cued), which is fired once the buffering has finished and the video is ready to play.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •