2

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?

Community
  • 1
  • 1
tinezekis
  • 93
  • 2
  • 9
  • 1
    Enabling the MIME type `video/mp4` is a requirement anyway to serve the files from your server.. http://www.iana.org/assignments/media-types/media-types.xhtml – Pogrindis Jan 19 '16 at 15:00
  • @Pogrindis, does this mean that I should go ahead and edit the .htaccess file, or is there another way to enable the MIME type? – tinezekis Jan 20 '16 at 15:17
  • 1
    What web server are you running ? The steps are different for IIS than for Apache for example, but it can be done without the modification of the `htaccess` certainly. – Pogrindis Jan 20 '16 at 15:22
  • @Pogrindis, I'm using Apache2. It looks like `video/mp4` is already listed in my `/etc/mime.types` file, so I'm assuming there is another place I need to make a change. – tinezekis Jan 20 '16 at 16:55

0 Answers0