jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/371715 )
Change subject: More careful order & size check for video sources ...................................................................... More careful order & size check for video sources Previously we always used the 'most preferred' codec if available, even if the size was wildly inappropriate. This caused slow playback of large VP9-encoded videos even when a more suitable VP8 or Ogg was available. Now discarding sources larger than the display size, unless it's the only thing available. Bug: T145925 Change-Id: I03ccd572ea386553df037e84ed896237c1f02e49 --- M MwEmbedModules/EmbedPlayer/resources/mw.MediaElement.js 1 file changed, 32 insertions(+), 33 deletions(-) Approvals: Brion VIBBER: Looks good to me, approved jenkins-bot: Verified Jforrester: Looks good to me, approved diff --git a/MwEmbedModules/EmbedPlayer/resources/mw.MediaElement.js b/MwEmbedModules/EmbedPlayer/resources/mw.MediaElement.js index 9af4899..f05558a 100644 --- a/MwEmbedModules/EmbedPlayer/resources/mw.MediaElement.js +++ b/MwEmbedModules/EmbedPlayer/resources/mw.MediaElement.js @@ -310,46 +310,45 @@ if( ! namedSourceSet[ codec ] ){ continue; } - if( namedSourceSet[ codec ].length == 1 ){ - mw.log('MediaElement::autoSelectSource: Set 1 source via EmbedPlayer.CodecPreference: ' + namedSourceSet[ codec ][0].getTitle() ); - return setSelectedSource( namedSourceSet[ codec ][0] ); - } else if( namedSourceSet[ codec ].length > 1 ) { - // select based on size: - // Set via embed resolution closest to relative to display size - var minSizeDelta = null; + // select based on size: + // Set via embed resolution closest to relative to display size + var minSizeDelta = null; - // unless we're really slow... - var isBogoSlow = useBogoSlow && OGVCompat.isSlow(); + // unless we're really slow... + var isBogoSlow = useBogoSlow && OGVCompat.isSlow(); - if( this.parentEmbedId ){ - var displayWidth = $('#' + this.parentEmbedId).width(); - $.each( namedSourceSet[ codec ], function(inx, source ){ - if ( ( isBogoSlow && source.height > 240 ) - || (useBogoSlow && source.height > 360 ) ) { - // On iOS or slow Windows devices, large videos decoded in JavaScript are a bad idea! + if( this.parentEmbedId ){ + var displayWidth = $('#' + this.parentEmbedId).width(); + $.each( namedSourceSet[ codec ], function(inx, source ){ + if ( ( isBogoSlow && source.height > 240 ) + || (useBogoSlow && source.height > 360 ) ) { + // On iOS or slow Windows devices, large videos decoded in JavaScript are a bad idea! + // continue + return true; + } + if( source.width && displayWidth ){ + if ( source.width > displayWidth ) { + // Bigger than the space to display? + // Skip it unless it's the only one that fits. // continue return true; } - if( source.width && displayWidth ){ - var sizeDelta = Math.abs( source.width - displayWidth ); - mw.log('MediaElement::autoSelectSource: size delta : ' + sizeDelta + ' for s:' + source.width ); - if( minSizeDelta == null || sizeDelta < minSizeDelta){ - minSizeDelta = sizeDelta; - setSelectedSource( source ); - } + var sizeDelta = Math.abs( source.width - displayWidth ); + mw.log('MediaElement::autoSelectSource: size delta : ' + sizeDelta + ' for s:' + source.width ); + if( minSizeDelta == null || sizeDelta < minSizeDelta){ + minSizeDelta = sizeDelta; + setSelectedSource( source ); } - }); - } - // If we found a source via display size return: - if ( this.selectedSource ) { - mw.log('MediaElement::autoSelectSource: from ' + this.selectedSource.mimeType + ' because of resolution:' + this.selectedSource.width + ' close to: ' + displayWidth ); - return this.selectedSource; - } - // if no size info is set just select the first source: - if( namedSourceSet[ codec ][0] ){ - return setSelectedSource( namedSourceSet[ codec ][0] ); - } + } + // Fall through to next one... + }); } + // If we found a source via display size return: + if ( this.selectedSource ) { + mw.log('MediaElement::autoSelectSource: from ' + this.selectedSource.mimeType + ' because of resolution:' + this.selectedSource.width + ' close to: ' + displayWidth ); + return this.selectedSource; + } + // else fall through to defaults... }; } -- To view, visit https://gerrit.wikimedia.org/r/371715 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I03ccd572ea386553df037e84ed896237c1f02e49 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TimedMediaHandler Gerrit-Branch: master Gerrit-Owner: Brion VIBBER <br...@wikimedia.org> Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits