72301

How to get time passed since video started with YouTube iframe api?

Question:

I want to get time passed (in percent) since video started in using YouTube iframe api.

I've done this so far:

$(".timeInPercent").click(function() { var playerTotalTime = player.getDuration(); var playerCurrentTime = Math.round(player.getCurrentTime()); var playerTimeDifference = playerTotalTime / playerCurrentTime; var playerTimePercent = playerTimeDifference * 100; progress(playerTimePercent, $('#progressBar')); });

I need this for a custom progression bar I made. I just need to update this progress(playerTimePercent, $('#progressBar')); with time passed in percent.

Answer1:

You need playerCurrentTime / playerTotalTime, rather than the other way around. Then multiply by 100 to get percentage, as you're doing.

Recommend

  • PHP mysql_real_escape_string() and % character
  • Pie Chart Labels Cut off
  • Why does my regular expression fail with certain substitutions?
  • HTML5 video only works in IE. The other browsers shows the black screen
  • Possible to “watch” both HAML and SASS at the same time?
  • How to print columns containing value
  • NUnit 3.0 TestCase const custom object arguments
  • xcode don't localize specific strings
  • Create Instant using a negative year
  • Calling Worksheet functions from vba in foreign language versions of Excel
  • Does it make sense to call System.gc() and Thread.sleep() when working on Bitmaps?
  • Do I need to reset a Perl hash index?
  • Is there a way to do normal logging with EureakLog?
  • How to attach a node.js readable stream to a Sendgrid email?
  • Alert pop up with LWUIT
  • Get one-time binding to work for ng-if
  • Why ng-show works with ng-repeat but ng-if doesn't? [duplicate]
  • Fetching methods from BroadcastReceiver to update UI
  • How to recover from a Spring Social ExpiredAuthorizationException
  • Does CUDA 5 support STL or THRUST inside the device code?
  • javascript inside java/jsp code
  • MySQL WHERE-condition in procedure ignored
  • Hazelcast - OperationTimeoutException
  • Adding custom controls to a full screen movie
  • jquery mobile loadPage not working
  • RestKit - RKRequestDelegate does not exist
  • Data Validation Drop Down Box Arrow Disappearing
  • Revoking OAuth Access Token Results in 404 Not Found
  • using HTMLImports.whenReady not working in chrome
  • How do you join a server to an Active Directory (domain)?
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • Authorize attributes not working in MVC 4
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • EntityFramework adding new object to nested object collection
  • Binding checkboxes to object values in AngularJs
  • Net Present Value in Excel for Grouped Recurring CF
  • playing video using jmf
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?