Mdale has uploaded a new change for review.

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


Change subject: More accurate timming for captions, progress event fixes
......................................................................

More accurate timming for captions, progress event fixes

* bind to "progress" instead of monitorEvent for more accurate captions timing
* don't rebind events on showThumbnail results in broken click to pause on 
replay
* reset buffer indicator on click complete
* removed manual progress binding ( was only useful for old e.loaded && e.total 
HTML5 api )
* pass instance id in hide and show control bar ( captions were moving in 
diffrent players )

Change-Id: I78360cb4be16c2c5684be590ab23686fa901f12d
---
M MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayer.js
M MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayerNative.js
M MwEmbedModules/EmbedPlayer/resources/skins/mw.PlayerControlBuilder.js
M MwEmbedModules/TimedText/resources/mw.TimedText.js
4 files changed, 21 insertions(+), 35 deletions(-)


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

diff --git a/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayer.js 
b/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayer.js
index 25500d1..2fbb0b1 100644
--- a/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayer.js
+++ b/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayer.js
@@ -6,7 +6,6 @@
 * mediaElement Represents source media elements
 * mw.PlayerControlBuilder Handles skinning of the player controls
 */
-
 ( function( mw, $ ) {"use strict";
        /**
         * Merge in the default video attributes supported by embedPlayer:
@@ -1038,8 +1037,6 @@
 
                        this.paused = true;
                        this.stopped = true;
-                       // Make sure the controlBuilder bindings are up-to-date
-                       this.controlBuilder.addControlBindings();
 
                        // Once the thumbnail is shown run the mediaReady 
trigger (if not using native controls)
                        if( !this.useNativePlayerControls() ){
@@ -2242,6 +2239,9 @@
                        this.updatePlayHead( 0 );
                        // update the status:
                        this.controlBuilder.setStatus( this.getTimeRange() );
+                       // reset buffer indicator: 
+                       this.bufferedPercent = 0;
+                       this.updateBufferStatus();
                },
 
                /**
@@ -2594,8 +2594,6 @@
                updateBufferStatus: function() {
                        // Get the buffer target based for playlist vs clip
                        var $buffer = this.getInterface().find( '.mw_buffer' );
-
-                       // mw.log(' set bufferd %:' + this.bufferedPercent );
                        // Update the buffer progress bar (if available )
                        if ( this.bufferedPercent != 0 ) {
                                // mw.log('Update buffer css: ' + ( 
this.bufferedPercent * 100 ) +
diff --git a/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayerNative.js 
b/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayerNative.js
index 85d7e94..6ceee4a 100644
--- a/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayerNative.js
+++ b/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayerNative.js
@@ -286,6 +286,9 @@
                        $( vid ).unbind( eventName + 
'.embedPlayerNative').bind( eventName + '.embedPlayerNative', function(){
                                if( _this._propagateEvents ){
                                        var argArray = $.makeArray( arguments );
+                                       // always pass the current ref id as 
the last argument 
+                                       // helps check against some event 
trigger ref issues in jQuery
+                                       argArray.push( _this.id );
                                        // Check if there is local handler:
                                        if( _this[ '_on' + eventName ] ){
                                                _this[ '_on' + eventName 
].apply( _this, argArray);
@@ -1041,23 +1044,6 @@
                if( ! this.mediaLoadedFlag ){
                        $( this ).trigger( 'mediaLoaded' );
                        this.mediaLoadedFlag = true;
-               }
-       },
-
-       /**
-       * Local method for progress event
-       * fired as the video is downloaded / buffered
-       *
-       * Used to update the bufferedPercent
-       *
-       * Note: this way of updating buffer was only supported in Firefox 3.x 
and
-       * not supported in Firefox 4.x
-       */
-       _onprogress: function( event ) {
-               var e = event.originalEvent;
-               if( e && e.loaded && e.total ) {
-                       this.bufferedPercent = e.loaded / e.total;
-                       this.progressEventData = e.loaded;
                }
        },
 
diff --git 
a/MwEmbedModules/EmbedPlayer/resources/skins/mw.PlayerControlBuilder.js 
b/MwEmbedModules/EmbedPlayer/resources/skins/mw.PlayerControlBuilder.js
index 30f0204..b0a8275 100644
--- a/MwEmbedModules/EmbedPlayer/resources/skins/mw.PlayerControlBuilder.js
+++ b/MwEmbedModules/EmbedPlayer/resources/skins/mw.PlayerControlBuilder.js
@@ -971,8 +971,10 @@
                        embedPlayer.updatePlayheadStatus()
                });
 
-               // Update buffer information TODO move to controlBuilder
-               $( embedPlayer ).bind( 'progress' + this.bindPostfix, 
function(){
+               // Update buffer information 
+               $( embedPlayer ).bind( 'progress' + this.bindPostfix, function( 
event, jEvent, id){
+                       // regain scope
+                       var embedPlayer = $( '#' + id )[0];
                        embedPlayer.updateBufferStatus();
                });
 
@@ -1200,10 +1202,10 @@
                        }, dblClickTime );
                        return true;
                };
-               if (!embedPlayer.addEventListener) {
+               // Add click binding: ( $(embedPlayer).click ) has scope issues 
)
+               if ( embedPlayer.attachEvent ) {
                        embedPlayer.attachEvent("onclick", playerClickCb);
                } else{
-                       // For some reason jquery .bind( 'click' ) is doing 
evil things
                        // Firefox 3.5 requires third argument to 
addEventListener
                        embedPlayer.addEventListener('click', playerClickCb, 
false );
                }
@@ -1246,7 +1248,7 @@
                        .fadeOut( animateDuration );
                //mw.log('about to trigger hide control bar')
                // Allow interface items to update:
-               $( this.embedPlayer ).trigger('onHideControlBar', {'bottom' : 
15} );
+               $( this.embedPlayer ).trigger('onHideControlBar', [ {'bottom' : 
15}, this.embedPlayer.id ] );
 
        },
        restoreControlsHover:function(){
@@ -1276,9 +1278,9 @@
                }
 
                // Trigger the screen overlay with layout info:
-               $( this.embedPlayer ).trigger( 'onShowControlBar', {
+               $( this.embedPlayer ).trigger( 'onShowControlBar', [{
                        'bottom' : this.getHeight() + 15
-               } );
+               }, this.embedPlayer.id ] );
        },
 
        /**
diff --git a/MwEmbedModules/TimedText/resources/mw.TimedText.js 
b/MwEmbedModules/TimedText/resources/mw.TimedText.js
index aed646c..f4e18ab 100644
--- a/MwEmbedModules/TimedText/resources/mw.TimedText.js
+++ b/MwEmbedModules/TimedText/resources/mw.TimedText.js
@@ -153,7 +153,7 @@
                        // Check for timed text support:
                        _this.addInterface();
 
-                       $( embedPlayer ).bind( 'monitorEvent' + 
this.bindPostFix, function( event, id ) {
+                       $( embedPlayer ).bind( 'progress' + this.bindPostFix, 
function( event, jEvent, id ) {
                                // regain scope
                                _this = $('#' + id)[0].timedText;
                                // monitor text updates
@@ -215,10 +215,9 @@
                        });
 
                        // Setup display binding
-                       $( embedPlayer ).bind( 'onShowControlBar'+ 
this.bindPostFix, function(event, layout ){
-                               if( event.currentTarget.id != embedPlayer.id ){
-                                       embedPlayer = $('#' 
+event.currentTarget.id )[0];
-                               }
+                       $( embedPlayer ).bind( 'onShowControlBar'+ 
this.bindPostFix, function(event, layout, id ){
+                               // update embedPlayer ref:
+                               var embedPlayer = $('#' + id )[0];
                                if ( 
embedPlayer.controlBuilder.isOverlayControls() ) {
                                        // Move the text track if present
                                        embedPlayer.getInterface().find( 
'.track' )
@@ -227,7 +226,8 @@
                                }
                        });
 
-                       $( embedPlayer ).bind( 'onHideControlBar' + 
this.bindPostFix, function(event, layout ){
+                       $( embedPlayer ).bind( 'onHideControlBar' + 
this.bindPostFix, function(event, layout, id ){
+                               var embedPlayer = $('#' + id )[0];
                                if ( 
embedPlayer.controlBuilder.isOverlayControls() ) {
                                        // Move the text track down if present
                                        embedPlayer.getInterface().find( 
'.track' )

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I78360cb4be16c2c5684be590ab23686fa901f12d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TimedMediaHandler
Gerrit-Branch: master
Gerrit-Owner: Mdale <md...@wikimedia.org>

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

Reply via email to