Video.js jQuery disrupting video play/pause functions in Microsoft Edge

情到浓时终转凉″ 提交于 2019-12-02 04:35:15

问题


I am trying to use video.js to prevent fast-forward, but allow rewind, for mp4 videos on a Moodle site. The following script works in Chrome and Opera, but not in Microsoft Edge:

window.onload = function() {
  if ($('iframe').length > 0) {

    $('iframe').ready(function() {
      var videoPlayer = $('iframe').contents().find('video')[0];

      var cssLink = document.createElement("link")
      cssLink.href = "https://vjs.zencdn.net/5.0/video-js.min.css";
      cssLink.rel = "stylesheet";
      cssLink.type = "text/css";
      $('iframe').contents().find('head').append(cssLink);

      videojs(videoPlayer, {}, function() {
        var vjsPlayer = this;
        $('iframe').contents().find('video').prop('controls', 'true');
        $('iframe').contents().find('div .vjs-big-play-button').html('');
        $('iframe').contents().find('div .vjs-control-bar').html('');
        $('iframe').contents().find('div .vjs-caption-settings').html('');

        var currentTime = 0;

        vjsPlayer.on("seeking", function(event) {
          if (currentTime < vjsPlayer.currentTime()) {
            vjsPlayer.currentTime(currentTime);
          }
        });

        vjsPlayer.on("seeked", function(event) {
          if (currentTime < vjsPlayer.currentTime()) {
            vjsPlayer.currentTime(currentTime);
          }
        });

        setInterval(function() {
          if (!vjsPlayer.paused()) {
            currentTime = vjsPlayer.currentTime();
          }
        }, 1000);
      });
    });
  }
}

In Edge, the desired effect is achieved (seeking forward does not change the time on the video, but seeking backward does), however, the play/pause functions are broken. If I have seeked an odd number of times in either direction, the video is paused and only plays when holding down the play button. If I have seeked an even number of times (including zero), the video plays but the pause button does nothing. I get the same results in Firefox, and have posted a question about that as well.

I tried to add a type="video/mp4" attribute to the video tag, but this had no effect on the problem.

Additionally, I have seen a suggestion to add AddType video/mp4 .mp4 to the .htaccess file, but I'm worried about doing that in Moodle. The content of the .htaccess file is:

deny from all
AllowOverride None
Note: this file is broken intentionally, we do not want anybody to undo it in subdirectory!

What would the consequences be of editing this?

Are there any other suggestions for getting the mp4 videos working properly with Microsoft Edge?

来源:https://stackoverflow.com/questions/34880021/video-js-jquery-disrupting-video-play-pause-functions-in-microsoft-edge

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!