Question

This fiddle is copied from the official sample given here, but getCurrentTime() always seems to return 0 on IE0. Has anyone run into the same problem before?

Was it helpful?

Solution 2

It was due to the way the iframe API tackles flash/html5 support.

Unlike the Flash and JavaScript player APIs, which both involve embedding a Flash object on your web page, the IFrame API posts content to an tag on your page. This approach provides more flexibility than the previously available APIs since it allows YouTube to serve an HTML5 player rather than a Flash player for mobile devices that do not support Flash.

Which means it will:

  1. use html5 if only html5 video tag is available
  2. use flash if only flash is available
  3. use flash if both are available

For some reasons, when both are available, the flash one doesn't work properly. Known occasions where this happens are:

  1. IE10
  2. IE9
  3. OSX Safari, when user had installed flash in system

Two solutions:

  1. force use html5 video tag while both are available, by adding html5=1 in the src attribute of the iframe.
  2. Use the youtube javascript API instead on those occasions, which embeds flash in a more reliable way.

I've written a jQuery plugin implementing all the hacks and fixes, take what you need and hope it helps.

OTHER TIPS

yes, I am having a similar issue. For me, getCurrentTime() returns 0, but not always - when I play a youtube video, it works fine, but when I play a brightcove video following the youtube video, then go back to the youtube, it returns 0. Other people have issues that resemble this, there was a discussion here: https://productforums.google.com/forum/#!topic/youtube/F5CEukwhitA

the issue seems to be related to conflicts with other libraries, which I also believe is the case with my application. Try to remove other third-party libraries and turn off browser extensions and see if the problem is still there.

btw did you try to run the code outside of jsfiddle, i.e. in an app?


in my case, the reason why getCurrentTime() was returning 0 was that it was attached to nodes inside detached DOM trees. This is a known case when AngularJS and jQuery are used together, and references to non-existings (deleted) DOM elements remain in jQuery cache.

basically, check what node your player is attached to and also if you don't have any replicas.

it was the nested o object in the player object that put me on track. PlayerState was 3 all the time, there were no bytes downloaded, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top