J has submitted this change and it was merged.
Change subject: More accurate timming for captions, progress event fixes
......................................................................
More accurate timming for captions, progress event fixes
* bind to "timeupdate" 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 )
* pass milliseconds as milliseconds not seconds float in match2caption
Bug: 49408
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.TextSource.js
M MwEmbedModules/TimedText/resources/mw.TimedText.js
5 files changed, 25 insertions(+), 39 deletions(-)
Approvals:
J: Verified; Looks good to me, approved
jenkins-bot: Checked
diff --git a/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayer.js
b/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayer.js
index 25500d1..c8e4883 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..c090460 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..7a05153 100644
--- a/MwEmbedModules/EmbedPlayer/resources/skins/mw.PlayerControlBuilder.js
+++ b/MwEmbedModules/EmbedPlayer/resources/skins/mw.PlayerControlBuilder.js
@@ -873,7 +873,7 @@
// Trigger the onCloseFullscreen event:
$( embedPlayer ).trigger( 'onCloseFullScreen' );
- // Scroll back to the previews position ( do in async call to
allow dom fullscreen restore )
+ // Scroll back to the previews position ( do in async call to
allow dom fullscreen restore )
setTimeout( function(){
window.scroll( 0, _this.verticalScrollPosition );
}, 100 );
@@ -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 ] );
},
/**
@@ -2279,7 +2281,7 @@
* 'w' The width of the component
* 'h' The height of the component ( if height is undefined the height
of the control bar is used )
* 'position' elements are inserted into the dom based on component
order and available space.
- * if the element is inserted, position is then used to set relative
dom insert order.
+ * if the element is inserted, position is then used to set relative
dom insert order.
*/
components: {
/**
diff --git a/MwEmbedModules/TimedText/resources/mw.TextSource.js
b/MwEmbedModules/TimedText/resources/mw.TextSource.js
index 16613a1..217ae5a 100644
--- a/MwEmbedModules/TimedText/resources/mw.TextSource.js
+++ b/MwEmbedModules/TimedText/resources/mw.TextSource.js
@@ -478,8 +478,8 @@
match2caption: function( m ){
var caption = {};
// Look for ms:
- var startMs = (m[4])? (parseInt(m[4], 10) / 1000): 0;
- var endMs = (m[8])? (parseInt(m[8], 10) / 1000) : 0;
+ var startMs = (m[4]) ? parseInt(m[4], 10) : 0;
+ var endMs = (m[8]) ? parseInt(m[8], 10) : 0;
caption['start'] = this.timeParts2seconds( m[1], m[2],
m[3], startMs );
caption['end'] = this.timeParts2seconds( m[5], m[6],
m[7], endMs );
if( m[9] ){
diff --git a/MwEmbedModules/TimedText/resources/mw.TimedText.js
b/MwEmbedModules/TimedText/resources/mw.TimedText.js
index aed646c..f45f222 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( 'timeupdate' + 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: merged
Gerrit-Change-Id: I78360cb4be16c2c5684be590ab23686fa901f12d
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/TimedMediaHandler
Gerrit-Branch: master
Gerrit-Owner: Mdale <[email protected]>
Gerrit-Reviewer: J <[email protected]>
Gerrit-Reviewer: Mdale <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits