TheDJ has uploaded a new change for review.

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

Change subject: Made the dependency on videojs-ogvjs conditional
......................................................................

Made the dependency on videojs-ogvjs conditional

This saves about 112Kb compressed, so I think worth it.
TODO: Might want to merge some of this logic into ext.tmh.OgvJsSupport.js

Bug: T133228
Change-Id: Ia2f7a596ae1679e4aab85761d894945ac9929131
---
M TimedMediaHandler.hooks.php
M resources/ext.tmh.player.js
2 files changed, 26 insertions(+), 8 deletions(-)


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

diff --git a/TimedMediaHandler.hooks.php b/TimedMediaHandler.hooks.php
index 5dd38b0..6c867dc 100644
--- a/TimedMediaHandler.hooks.php
+++ b/TimedMediaHandler.hooks.php
@@ -162,7 +162,6 @@
                                        'dependencies' => [
                                                'ext.tmh.video-js',
                                                
'ext.tmh.videojs-resolution-switcher',
-                                               'ext.tmh.videojs-ogvjs',
                                                
'ext.tmh.videojs-responsive-layout',
                                                'ext.tmh.videojs-replay',
                                                'ext.tmh.mw-info-button',
diff --git a/resources/ext.tmh.player.js b/resources/ext.tmh.player.js
index 43fb7ea..31861ca 100755
--- a/resources/ext.tmh.player.js
+++ b/resources/ext.tmh.player.js
@@ -34,9 +34,6 @@
                        },
                        replayButton: {},
                        infoButton: {}
-               },
-               ogvjs: {
-                       base: mw.OgvJsSupport.basePath()
                }
        };
 
@@ -48,11 +45,11 @@
 
        /**
         * Load video players for a jQuery collection
-     */
+        */
        function loadVideoPlayer() {
-               var videoplayer, $videoplayer;
+               var videoplayer, $videoplayer, $collection = this;
 
-               this.each( function ( index ) {
+               function loadSinglePlayer( index ) {
                        videoplayer = this;
                        $videoplayer = $( this );
                        if ( $videoplayer.closest( '.video-js' ).size() ) {
@@ -129,7 +126,29 @@
                        videojs( videoplayer, playerConfig ).ready( function () 
{
                                /* More custom stuff goes here */
                        } );
-               } );
+               }
+
+               if( isOGVSupported() ) {
+                       $collection.each( loadSinglePlayer );
+               } else {
+                       mw.loader.using( 'ext.tmh.videojs-ogvjs' ).then( 
function() {
+                               globalConfig.ogvjs = {
+                                       base: mw.OgvJsSupport.basePath()
+                               };
+                               $collection.each( loadSinglePlayer );
+                       } );
+               }
+       }
+
+       function isOGVSupported() {
+               var el = document.createElement('video');
+               if( el && el.canPlayType && el.canPlayType( 'application/ogg' ) 
) {
+                       return true;
+               }
+               return false;
+       }
+       if( !isOGVSupported() ) {
+               mw.loader.load( 'ext.tmh.videojs-ogvjs' );
        }
 
        $.fn.loadVideoPlayer = loadVideoPlayer;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia2f7a596ae1679e4aab85761d894945ac9929131
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