mozilla / popcorn-js

The HTML5 Media Framework. (Unmaintained. See https://github.com/menismu/popcorn-js for activity)
MIT License
2.14k stars 632 forks source link

Youtube video does not work under IE11. #453

Open kristofferwiklund opened 9 years ago

kristofferwiklund commented 9 years ago

I have a very simple page.

<html>
  <head>
    <script src="/popcorn-js/dist/popcorn-complete.js"></script>
    <style>
      #video {
        width: 400px;
        height: 300px;
      }
    </style>
  </head>
  <body>
    <h1>Video</h1>
    <div id="video"></div>
    <script>
      var wrapper = Popcorn.HTMLYouTubeVideoElement("#video");
      wrapper.src = "https://www.youtube.com/watch?v=F7HcoKv11i0";
      var pop = Popcorn(wrapper);
      pop.play();
    </script>
  </body>
</html>

I have tried several prebuild version and also build one from source. The above code works nice in Chrome and Firefox on Windows. But with Internet Explorer 11 the video is loaded but nothing of popcornjs is run. The autoplay nor plugins are run.

On Mac and Safari the video is autoplaying as it should

I have also tried loading the video with:

  document.addEventListener("DOMContentLoaded", function () {
    var pop = Popcorn.youtube(
      '#video',
      'https://www.youtube.com/watch?v=F7HcoKv11i0' );
    pop.play();
  }, false);

As documented here http://popcornjs.org/popcorn-with-youtube. (Btw the demo is not working because of old version of popcornjs)

TwoD commented 9 years ago

I have looked into this briefly and it appears that the YouTube plugin is getting stuck in onFirstPause, waiting for getCurrentTime() to return 0, which it never does.

There is a player.seekTo(0) in onFirstPlayed() just before the player is paused. The paused event does fire, but the current time is stuck at just a few 1/100s when it does. Simply changing the getCurrentTime() comparison to make it > 0.2s or so will make it work reliably (autoplay, cues, seeking etc).

Stranglely enough, the problem only appears to happen when the files are fetched from the browser cache. Refreshing from the server with Ctrl+F5 made it autoplay without the change.