Brian Wolff has uploaded a new change for review. https://gerrit.wikimedia.org/r/144352
Change subject: Android native browser ending playback after 1 second ...................................................................... Android native browser ending playback after 1 second On my android 4.3 phone (using native browser. Issue not present on firefox or chrome apps) video duration seems to be set to precisely 1 from the metadataloaded event. There was an existing check there for android 4.0, which appearently wasn't sufficient. My phone is 4.3 and issue is present. Googling suggests the bug is on versions prior to 4 too. I was originally going to try and match based on user-agent, but its unclear how to match that particular browser's user-agent. It gives one of either "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.34 Safari/534.24" or "Mozilla/5.0 (Linux; U; Android 4.3; en-ca; SGH-I747M Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30" depending on if "fetch desktop version" is selected, and those user agents tend to look a lot like the user-agents for other browsers. Instead I check if the new duration being set is precisely 1 (Seems rather unlikely for a video to be precisely 1.0 seconds), and if it is decreasing the duration from a previous longer duration. If those two conditions are met, then it doesn't update the duration. This seems much more robust than the user-agent check. In most cases the duration update isn't really very important (duration also gets specified by other means), so if the update is missed, it probably won't cause badness anyways. Bug: 43748 Change-Id: Icc6f756ed6be89f92016a23195373f81fd5cffb7 --- M MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayerNative.js 1 file changed, 6 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler refs/changes/52/144352/1 diff --git a/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayerNative.js b/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayerNative.js index c090460..6051ab9 100644 --- a/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayerNative.js +++ b/MwEmbedModules/EmbedPlayer/resources/mw.EmbedPlayerNative.js @@ -676,8 +676,9 @@ $( vid ).bind( 'loadedmetadata' + switchBindPostfix, function(){ $( vid ).unbind( 'loadedmetadata' + switchBindPostfix); mw.log("EmbedPlayerNative:: playerSwitchSource> loadedmetadata callback for:" + src + ' switchCallback: ' + switchCallback ); - // Update the duration ( if not android 4 which gives bad duration ) - if( !mw.isAndroid40() ){ + // Android native browser reports a bad duration of 1 here. + // Don't reduce duration to 1 if its currently higher. + if( !( vid.duration === 1 && _this.duration && vid.duration < _this.duration ) ) { _this.duration = vid.duration; } // keep going towards playback! if switchCallback has not been called yet @@ -1024,8 +1025,9 @@ if ( this.playerElement && !isNaN( this.playerElement.duration ) && isFinite( this.playerElement.duration) ) { mw.log( 'EmbedPlayerNative :onloadedmetadata metadata ready Update duration:' + this.playerElement.duration + ' old dur: ' + this.getDuration() ); - // update duration if not android 4 ( gives bad duration ) - if( !mw.isAndroid40() ){ + // Android native browser (but not chrome app) gives bad duration of precisely 1 here. + // So don't change duration if the new value is exactly 1 and is less than current duration. + if( !( this.playerElement.duration === 1 && this.duration && this.playerElement.duration < this.duration ) ) { this.duration = this.playerElement.duration; } } -- To view, visit https://gerrit.wikimedia.org/r/144352 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icc6f756ed6be89f92016a23195373f81fd5cffb7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TimedMediaHandler Gerrit-Branch: master Gerrit-Owner: Brian Wolff <bawolff...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits