TheDJ has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/285091

Change subject: Update videojs-ogvjs tech plugin to v1.1.1
......................................................................

Update videojs-ogvjs tech plugin to v1.1.1

Change-Id: I2501b0a996a77f8455715738aecb5aa225eced2d
---
M Gruntfile.js
M package.json
M resources/videojs-ogvjs/videojs-ogvjs.js
D resources/videojs-ogvjs/videojs-ogvjs.min.js
4 files changed, 121 insertions(+), 145 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler 
refs/changes/91/285091/1

diff --git a/Gruntfile.js b/Gruntfile.js
index acadfd5..f894208 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -66,7 +66,7 @@
                        'videojs-ogvjs': {
                                expand: true,
                                cwd: 'node_modules/videojs-ogvjs/dist/',
-                               src: [ '**' ],
+                               src: [ '**', '!**/*.min.js' ],
                                dest: 'resources/videojs-ogvjs/'
                        },
                        'videojs-resolution-switcher': {
diff --git a/package.json b/package.json
index 9d93202..c1ca728 100644
--- a/package.json
+++ b/package.json
@@ -15,7 +15,7 @@
     "grunt-patch": "^0.1.7",
     "jscs-preset-wikimedia": "~1.0.0",
     "video.js": "^5.8.8",
-    "videojs-ogvjs": "^1.0.6",
+    "videojs-ogvjs": "^1.1.0",
     "videojs-resolution-switcher": "^0.4.2",
     "videojs-responsive-layout": "^1.1.0"
   }
diff --git a/resources/videojs-ogvjs/videojs-ogvjs.js 
b/resources/videojs-ogvjs/videojs-ogvjs.js
index 38d32dd..8ac48f8 100644
--- a/resources/videojs-ogvjs/videojs-ogvjs.js
+++ b/resources/videojs-ogvjs/videojs-ogvjs.js
@@ -1,7 +1,7 @@
 /**
  * videojs-ogvjs
- * @version 1.0.6
- * @copyright 2015 Derk-Jan Hartman
+ * @version 1.1.1
+ * @copyright 2016 Derk-Jan Hartman
  * @license (MIT OR Apache-2.0)
  */
 (function(f){if(typeof exports==="object"&&typeof 
module!=="undefined"){module.exports=f()}else if(typeof 
define==="function"&&define.amd){define([],f)}else{var g;if(typeof 
window!=="undefined"){g=window}else if(typeof 
global!=="undefined"){g=global}else if(typeof 
self!=="undefined"){g=self}else{g=this}g.videojsOgvjs = f()}})(function(){var 
define,module,exports;return (function e(t,n,r){function 
s(o,u){if(!n[o]){if(!t[o]){var a=typeof 
require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var 
f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var 
l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return 
s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof 
require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return 
s})({1:[function(require,module,exports){
@@ -57,13 +57,22 @@
 
     _get(Object.getPrototypeOf(Ogvjs.prototype), 'constructor', 
this).call(this, options, ready);
 
+    // Set initial state of player
+    this.el_.src = options.source.src;
+    Ogvjs.setIfAvailable(this.el_, 'autoplay', options.autoplay);
+    Ogvjs.setIfAvailable(this.el_, 'loop', options.loop);
+    Ogvjs.setIfAvailable(this.el_, 'poster', options.poster);
+    Ogvjs.setIfAvailable(this.el_, 'preload', options.preload);
+
     this.triggerReady();
   }
 
   /*
-   * Check if Ogvjs video is supported by this browser/device
+   * Only set a value on an element if it has that property
    *
-   * @return {Boolean}
+   * @param {Element} el
+   * @param {String} name
+   * @param value
    */
 
   /**
@@ -75,7 +84,7 @@
   _createClass(Ogvjs, [{
     key: 'dispose',
     value: function dispose() {
-      // Ogvjs.disposeMediaElement(this.el_);
+      this.el_.removeEventListener('framecallback', this.onFrameUpdate);
       _get(Object.getPrototypeOf(Ogvjs.prototype), 'dispose', this).call(this);
     }
 
@@ -98,12 +107,15 @@
 
       var el = new _OGVPlayer2['default'](options);
 
-      // simulate timeupdate events, needed for subtitles
-      // @todo switch this to native timeupdate event when available upstream
-      this.lastTime = 0;
-      el.addEventListener('framecallback', this.onFrameUpdate.bind(this));
-      el.src = this.options_.source.src;
+      if (!el.hasOwnProperty('preload')) {
+        // simulate timeupdate events for older ogv.js versions pre 1.1 
versions
+        // needed for subtitles. preload is only defined in 1.1 and later,
+        this.lastTime = 0;
+        el.addEventListener('framecallback', this.onFrameUpdate.bind(this));
+      }
+
       el.className += ' vjs-tech';
+      options.tag = el;
 
       return el;
     }
@@ -218,7 +230,7 @@
   }, {
     key: 'volume',
     value: function volume() {
-      return this.el_.volume ? this.el_.volume : 1;
+      return this.el_.hasOwnProperty('volume') ? this.el_.volume : 1;
     }
 
     /**
@@ -230,7 +242,7 @@
   }, {
     key: 'setVolume',
     value: function setVolume(percentAsDecimal) {
-      if (this.el_.volume) {
+      if (this.el_.hasOwnProperty('volume')) {
         this.el_.volume = percentAsDecimal;
       }
     }
@@ -244,7 +256,7 @@
   }, {
     key: 'muted',
     value: function muted() {
-      return this.el_.muted ? this.el_.muted : false;
+      return this.el_.muted;
     }
 
     /**
@@ -256,9 +268,7 @@
   }, {
     key: 'setMuted',
     value: function setMuted(muted) {
-      if (this.el_.muted) {
-        this.el_.muted = muted;
-      }
+      this.el_.muted = !!muted;
     }
 
     /**
@@ -283,73 +293,6 @@
     key: 'height',
     value: function height() {
       return this.el_.offsetHeight;
-    }
-
-    /**
-     * Get if there is fullscreen support
-     *
-     * @return {Boolean}
-     * @method supportsFullScreen
-     */
-  }, {
-    key: 'supportsFullScreen',
-    value: function supportsFullScreen() {
-      if (typeof this.el_.webkitEnterFullScreen === 'function') {
-        var userAgent = window.navigator.userAgent;
-
-        // Seems to be broken in Chromium/Chrome && Safari in Leopard
-        if (/Android/.test(userAgent) || !/Chrome|Mac OS X 
10.5/.test(userAgent)) {
-          return true;
-        }
-      }
-      return false;
-    }
-
-    /**
-     * Request to enter fullscreen
-     *
-     * @method enterFullScreen
-     */
-  }, {
-    key: 'enterFullScreen',
-    value: function enterFullScreen() {
-      var video = this.el_;
-
-      if ('webkitDisplayingFullscreen' in video) {
-        this.one('webkitbeginfullscreen', function () {
-          this.one('webkitendfullscreen', function () {
-            this.trigger('fullscreenchange', { isFullscreen: false });
-          });
-
-          this.trigger('fullscreenchange', { isFullscreen: true });
-        });
-      }
-
-      if (video.paused && video.networkState <= video.HAVE_METADATA) {
-        // attempt to prime the video element for programmatic access
-        // this isn't necessary on the desktop but shouldn't hurt
-        this.el_.play();
-
-        // playing and pausing synchronously during the transition to 
fullscreen
-        // can get iOS ~6.1 devices into a play/pause loop
-        this.setTimeout(function () {
-          video.pause();
-          video.webkitEnterFullScreen();
-        }, 0);
-      } else {
-        video.webkitEnterFullScreen();
-      }
-    }
-
-    /**
-     * Request to exit fullscreen
-     *
-     * @method exitFullScreen
-     */
-  }, {
-    key: 'exitFullScreen',
-    value: function exitFullScreen() {
-      this.el_.webkitExitFullScreen();
     }
 
     /**
@@ -438,7 +381,11 @@
      * @return {String}
      * @method preload
      */
-    // preload() { return this.el_.preload; }
+  }, {
+    key: 'preload',
+    value: function preload() {
+      return this.el_.preload || 'none';
+    }
 
     /**
      * Set preload attribute
@@ -446,63 +393,92 @@
      * @param {String} val Value for preload attribute
      * @method setPreload
      */
-    // setPreload(val) { this.el_.preload = val; }
+  }, {
+    key: 'setPreload',
+    value: function setPreload(val) {
+      if (this.el_.hasOwnProperty('preload')) {
+        this.el_.preload = val;
+      }
+    }
 
     /**
      * Get autoplay attribute
      *
-     * @return {String}
+     * @return {Boolean}
      * @method autoplay
      */
-    // autoplay() { return this.el_.autoplay; }
+  }, {
+    key: 'autoplay',
+    value: function autoplay() {
+      return this.el_.autoplay || false;
+    }
 
     /**
      * Set autoplay attribute
      *
-     * @param {String} val Value for preload attribute
+     * @param {Boolean} val Value for preload attribute
      * @method setAutoplay
      */
-    // setAutoplay(val) { this.el_.autoplay = val; }
+  }, {
+    key: 'setAutoplay',
+    value: function setAutoplay(val) {
+      if (this.el_.hasOwnProperty('autoplay')) {
+        this.el_.autoplay = !!val;
+        return;
+      }
+    }
 
     /**
      * Get controls attribute
      *
-     * @return {String}
+     * @return {Boolean}
      * @method controls
      */
   }, {
     key: 'controls',
     value: function controls() {
-      return this.el_.controls;
+      return this.el_controls || false;
     }
 
     /**
      * Set controls attribute
      *
-     * @param {String} val Value for controls attribute
+     * @param {Boolean} val Value for controls attribute
      * @method setControls
      */
   }, {
     key: 'setControls',
     value: function setControls(val) {
-      this.el_.controls = !!val;
+      if (this.el_.hasOwnProperty('controls')) {
+        this.el_.controls = !!val;
+      }
     }
 
     /**
      * Get loop attribute
      *
-     * @return {String}
+     * @return {Boolean}
      * @method loop
      */
-    // loop() { return this.el_.loop; }
+  }, {
+    key: 'loop',
+    value: function loop() {
+      return this.el_.loop || false;
+    }
 
     /**
      * Set loop attribute
      *
-     * @param {String} val Value for loop attribute
+     * @param {Boolean} val Value for loop attribute
      * @method setLoop
      */
-    // setLoop(val) { this.el_.loop = val; }
+  }, {
+    key: 'setLoop',
+    value: function setLoop(val) {
+      if (this.el_.hasOwnProperty('loop')) {
+        this.el_.loop = !!val;
+      }
+    }
 
     /**
      * Get error value
@@ -562,7 +538,11 @@
      * @return {Boolean}
      * @method defaultMuted
      */
-    // defaultMuted() { return this.el_.defaultMuted; }
+  }, {
+    key: 'defaultMuted',
+    value: function defaultMuted() {
+      return this.el_.defaultMuted || false;
+    }
 
     /**
      * Get desired speed at which the media resource is to play
@@ -570,7 +550,11 @@
      * @return {Number}
      * @method playbackRate
      */
-    // playbackRate() { return this.el_.playbackRate; }
+  }, {
+    key: 'playbackRate',
+    value: function playbackRate() {
+      return this.el_.playbackRate || 1;
+    }
 
     /**
      * Returns a TimeRanges object that represents the ranges of the
@@ -579,7 +563,11 @@
      * timeline that has been reached through normal playback
      * @see 
https://html.spec.whatwg.org/multipage/embedded-content.html#dom-media-played
      */
-    // played() { return this.el_.played; }
+  }, {
+    key: 'played',
+    value: function played() {
+      return this.el_.played;
+    }
 
     /**
      * Set desired speed at which the media resource is to play
@@ -587,7 +575,13 @@
      * @param {Number} val Speed at which the media resource is to play
      * @method setPlaybackRate
      */
-    // setPlaybackRate(val) { this.el_.playbackRate = val; }
+  }, {
+    key: 'setPlaybackRate',
+    value: function setPlaybackRate(val) {
+      if (this.el_.hasOwnProperty('playbackRate')) {
+        this.el_.playbackRate = val;
+      }
+    }
 
     /**
      * Get the current state of network activity for the element, from
@@ -600,7 +594,11 @@
      * @return {Number}
      * @method networkState
      */
-    // networkState() { return this.el_.networkState; }
+  }, {
+    key: 'networkState',
+    value: function networkState() {
+      return this.el_.networkState;
+    }
 
     /**
      * Get a value that expresses the current state of the element
@@ -615,7 +613,11 @@
      * @return {Number}
      * @method readyState
      */
-    // readyState() { return this.el_.readyState; }
+  }, {
+    key: 'readyState',
+    value: function readyState() {
+      return this.el_.readyState;
+    }
 
     /**
      * Get width of video
@@ -645,6 +647,17 @@
   return Ogvjs;
 })(Tech);
 
+Ogvjs.setIfAvailable = function (el, name, value) {
+  if (el.hasOwnProperty(name)) {
+    el[name] = value;
+  }
+};
+
+/*
+ * Check if Ogvjs video is supported by this browser/device
+ *
+ * @return {Boolean}
+ */
 Ogvjs.isSupported = function () {
   return _OGVCompat2['default'].supported('OGVPlayer');
 };
@@ -666,7 +679,9 @@
  * @return {Boolean}
  */
 Ogvjs.canControlVolume = function () {
-  return false;
+  var p = new _OGVPlayer2['default']();
+
+  return p.hasOwnProperty('volume');
 };
 
 /*
@@ -728,38 +743,6 @@
  * @type {Boolean}
  */
 Ogvjs.prototype.featuresNativeTextTracks = Ogvjs.supportsNativeTextTracks();
-
-Ogvjs.disposeMediaElement = function (el) {
-  if (!el) {
-    return;
-  }
-
-  if (el.parentNode) {
-    el.parentNode.removeChild(el);
-  }
-
-  // remove any child track or source nodes to prevent their loading
-  while (el.hasChildNodes()) {
-    el.removeChild(el.firstChild);
-  }
-
-  // remove any src reference. not setting `src=''` because that causes a 
warning
-  // in firefox
-  el.removeAttribute('src');
-
-  // force the media element to update its loading state by calling load()
-  // however IE on Windows 7N has a bug that throws an error so need a 
try/catch (#793)
-  if (typeof el.load === 'function') {
-    // wrapping in an iife so it's not deoptimized (#1060#discussion_r10324473)
-    (function () {
-      try {
-        el.load();
-      } catch (e) {
-        // not supported
-      }
-    })();
-  }
-};
 
 Tech.registerTech('Ogvjs', Ogvjs);
 exports['default'] = Ogvjs;
diff --git a/resources/videojs-ogvjs/videojs-ogvjs.min.js 
b/resources/videojs-ogvjs/videojs-ogvjs.min.js
deleted file mode 100644
index 705f44d..0000000
--- a/resources/videojs-ogvjs/videojs-ogvjs.min.js
+++ /dev/null
@@ -1,7 +0,0 @@
-/**
- * videojs-ogvjs
- * @version 1.0.6
- * @copyright 2015 Derk-Jan Hartman
- * @license (MIT OR Apache-2.0)
- */
-!function(e){if("object"==typeof exports&&"undefined"!=typeof 
module)module.exports=e();else if("function"==typeof 
define&&define.amd)define([],e);else{var t;t="undefined"!=typeof 
window?window:"undefined"!=typeof global?global:"undefined"!=typeof 
self?self:this,t.videojsOgvjs=e()}}(function(){return function 
e(t,n,r){function o(u,l){if(!n[u]){if(!t[u]){var a="function"==typeof 
require&&require;if(!l&&a)return a(u,!0);if(i)return i(u,!0);var s=new 
Error("Cannot find module '"+u+"'");throw s.code="MODULE_NOT_FOUND",s}var 
f=n[u]={exports:{}};t[u][0].call(f.exports,function(e){var n=t[u][1][e];return 
o(n?n:e)},f,f.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof 
require&&require,u=0;u<r.length;u++)o(r[u]);return 
o}({1:[function(e,t,n){(function(e){"use strict";function r(e){return 
e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new 
TypeError("Cannot call a class as a function")}function 
i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression 
must either be null or a function, not "+typeof 
t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(n,"__esModule",{value:!0});var
 u=function(){function e(e,t){for(var n=0;n<t.length;n++){var 
r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in 
r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return 
function(t,n,r){return 
n&&e(t.prototype,n),r&&e(t,r),t}}(),l=function(e,t,n){for(var r=!0;r;){var 
o=e,i=t,u=n;r=!1,null===o&&(o=Function.prototype);var 
l=Object.getOwnPropertyDescriptor(o,i);if(void 0!==l){if("value"in l)return 
l.value;var a=l.get;if(void 0===a)return;return a.call(u)}var 
s=Object.getPrototypeOf(o);if(null===s)return;e=s,t=i,n=u,r=!0,l=s=void 
0}},a="undefined"!=typeof window?window.videojs:"undefined"!=typeof 
e?e.videojs:null,s=r(a),f="undefined"!=typeof 
window?window.OGVCompat:"undefined"!=typeof 
e?e.OGVCompat:null,c=r(f),d="undefined"!=typeof 
window?window.OGVLoader:"undefined"!=typeof 
e?e.OGVLoader:null,p=r(d),y="undefined"!=typeof 
window?window.OGVPlayer:"undefined"!=typeof 
e?e.OGVPlayer:null,h=r(y),v=s["default"].getComponent("Tech"),k=function(e){function
 
t(e,n){o(this,t),l(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e,n),this.triggerReady()}return
 
i(t,e),u(t,[{key:"dispose",value:function(){l(Object.getPrototypeOf(t.prototype),"dispose",this).call(this)}},{key:"createEl",value:function(){var
 e=this.options_;if(!e.base)throw new Error("Please specify the base for the 
ogv.js library");p["default"].base=e.base;var t=new h["default"](e);return 
this.lastTime=0,t.addEventListener("framecallback",this.onFrameUpdate.bind(this)),t.src=this.options_.source.src,t.className+="
 vjs-tech",t}},{key:"onFrameUpdate",value:function(e){var 
t=.25,n=this.el_?this.el_.currentTime:this.lastTime;Math.abs(n-this.lastTime)>=t&&(this.lastTime=n,this.trigger("timeupdate"),this.trigger("durationchange"))}},{key:"play",value:function(){this.el_.play()}},{key:"pause",value:function(){this.el_.pause()}},{key:"paused",value:function(){return
 this.el_.paused}},{key:"currentTime",value:function(){return 
this.el_.currentTime}},{key:"setCurrentTime",value:function(e){try{this.el_.currentTime=e}catch(t){s["default"].log(t,"Video
 is not ready. (Video.js)")}}},{key:"duration",value:function(){return 
this.el_.duration||0}},{key:"buffered",value:function(){return 
this.el_.buffered}},{key:"volume",value:function(){return 
this.el_.volume?this.el_.volume:1}},{key:"setVolume",value:function(e){this.el_.volume&&(this.el_.volume=e)}},{key:"muted",value:function(){return
 
this.el_.muted?this.el_.muted:!1}},{key:"setMuted",value:function(e){this.el_.muted&&(this.el_.muted=e)}},{key:"width",value:function(){return
 this.el_.offsetWidth}},{key:"height",value:function(){return 
this.el_.offsetHeight}},{key:"supportsFullScreen",value:function(){if("function"==typeof
 this.el_.webkitEnterFullScreen){var 
e=window.navigator.userAgent;if(/Android/.test(e)||!/Chrome|Mac OS X 
10.5/.test(e))return!0}return!1}},{key:"enterFullScreen",value:function(){var 
e=this.el_;"webkitDisplayingFullscreen"in 
e&&this.one("webkitbeginfullscreen",function(){this.one("webkitendfullscreen",function(){this.trigger("fullscreenchange",{isFullscreen:!1})}),this.trigger("fullscreenchange",{isFullscreen:!0})}),e.paused&&e.networkState<=e.HAVE_METADATA?(this.el_.play(),this.setTimeout(function(){e.pause(),e.webkitEnterFullScreen()},0)):e.webkitEnterFullScreen()}},{key:"exitFullScreen",value:function(){this.el_.webkitExitFullScreen()}},{key:"src",value:function(e){return"undefined"==typeof
 e?this.el_.src:void 
this.setSrc(e)}},{key:"setSrc",value:function(e){this.el_.src=e}},{key:"load",value:function(){this.el_.load()}},{key:"currentSrc",value:function(){return
 
this.currentSource_?this.currentSource_.src:this.el_.currentSrc}},{key:"poster",value:function(){return
 
this.el_.poster}},{key:"setPoster",value:function(e){this.el_.poster=e}},{key:"controls",value:function(){return
 
this.el_.controls}},{key:"setControls",value:function(e){this.el_.controls=!!e}},{key:"error",value:function(){return
 this.el_.error}},{key:"seeking",value:function(){return 
this.el_.seeking}},{key:"seekable",value:function(){return 
this.el_.seekable}},{key:"ended",value:function(){return 
this.el_.ended}},{key:"videoWidth",value:function(){return 
this.el_.videoWidth}},{key:"videoHeight",value:function(){return 
this.el_.videoHeight}}]),t}(v);k.isSupported=function(){return 
c["default"].supported("OGVPlayer")},k.canPlaySource=function(e){return-1!==e.type.indexOf("/ogg")?"maybe":""},k.canControlVolume=function(){return!1},k.canControlPlaybackRate=function(){return!1},k.supportsNativeTextTracks=function(){return!1},k.Events=["loadstart","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","progress","play","pause","ratechange","volumechange"],k.prototype.featuresVolumeControl=k.canControlVolume(),k.prototype.featuresPlaybackRate=k.canControlPlaybackRate(),k.prototype.featuresFullscreenResize=!0,k.prototype.featuresProgressEvents=!0,k.prototype.featuresNativeTextTracks=k.supportsNativeTextTracks(),k.disposeMediaElement=function(e){if(e){for(e.parentNode&&e.parentNode.removeChild(e);e.hasChildNodes();)e.removeChild(e.firstChild);e.removeAttribute("src"),"function"==typeof
 
e.load&&!function(){try{e.load()}catch(t){}}()}},v.registerTech("Ogvjs",k),n["default"]=k,t.exports=n["default"]}).call(this,"undefined"!=typeof
 global?global:"undefined"!=typeof self?self:"undefined"!=typeof 
window?window:{})},{}]},{},[1])(1)});
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/285091
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2501b0a996a77f8455715738aecb5aa225eced2d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TimedMediaHandler
Gerrit-Branch: master
Gerrit-Owner: TheDJ <hartman.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to