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 6814283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:40:15+00:00 2026-05-26T20:40:15+00:00

Basically m trying to build a service where users a charged based on minutes

  • 0

Basically m trying to build a service where users a charged based on minutes of video consumed. However user would not billed if the video is buffered

So i need to calculate number of seconds the video is played. The counter should increment only if the video is played and not paused/buffered/stopped. Say if a user watches 5 mins for 5 times than the total counter should display 25 mins.

Here is the my code.. but the problem is that eventlistner fires in quick succession and counter gets incremented not in unproportionately to the video play time

Have a look at online running code here http://guwahaticity.com/vimeotest.html

Here is the code of the same

            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>   
        <script src="http://a.vimeocdn.com/js/froogaloop2.min.js"></script>   

 <script type="text/javascript">
    var counter = 0;
    jQuery(document).ready(function() {

        var playerID = document.querySelector('iframe');

        $f(playerID).addEvent('ready', ready);

        function ready(playerID) {
            Froogaloop(playerID).addEvent('playProgress', playProgress);

        }

        function playProgress() {
            counter = counter + 1;
            $(".playp").html(counter);
        }

    });
</script>


    <iframe class="vimeo" id="player1" src="http://player.vimeo.com/video/3718294?api=1&player_id=player1" width="500" height="281" frameborder="0"></iframe>

    <hr>
    This video has been played for <div class="playp"></div> 
  • 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-05-26T20:40:16+00:00Added an answer on May 26, 2026 at 8:40 pm

    Seems like the playProgress event is fired more than once a second. What about increasing the counter only if the last event was fired more than a second ago, like this:

    var last = new Date(0);
    
    function playProgress() {
    
       Date now = new Date();
    
       if(now.getTime() - last.getTime() >= 1000){
           counter = counter + 1;
           last = now;
           $(".playp").html(counter);
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically i'm trying to build a comment system. The user looks at a photo
I'm trying to build a JAX-RS based web service using IBM RAD 7.5.5 (which
I am trying to to build a Felix bundle in Eclipse. This basically includes
I'm not too familiar with networking in JAVA but what i'm basically trying to
Basically I am trying to restart a service from a php web page. Here
I'm trying to build some image algebra code that can work with images (basically
I'm trying to build a multidimensional array dynamically. What I want is basically this
Basically i am trying to build an application that uses SSIS to run a
I'm trying to build a parser that would be able to extract the data
I'm trying to build up a 2.5 engine with XNA. Basically, I want to

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.