From fc9c44ef8b4a3df6350b18c3105e65b32a00339a Mon Sep 17 00:00:00 2001 From: Dominic Date: Tue, 12 Nov 2013 15:08:12 -0800 Subject: [PATCH] Ensure videos resume if preload="none". Fixes #1. --- video-quality-selector.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/video-quality-selector.js b/video-quality-selector.js index 1d02872..1ea6dab 100644 --- a/video-quality-selector.js +++ b/video-quality-selector.js @@ -100,6 +100,7 @@ _V_.ResolutionMenuItem.prototype.onClick = function() { var player = this.player(), + video_el = player.el().firstChild, current_time = player.currentTime(), is_paused = player.paused(), button_nodes = player.controlBar.resolutionSelector.el().firstChild.children, @@ -108,7 +109,10 @@ // Do nothing if we aren't changing resolutions if ( player.getCurrentRes() == this.resolution ) { return; } - // Change the source and make sure we don't start the video over + // Make sure the loadedmetadata event will fire + if ( 'none' == video_el.preload ) { video_el.preload = 'metadata'; } + + // Change the source and make sure we don't start the video over player.src( player.availableRes[this.resolution] ).one( 'loadedmetadata', function() { player.currentTime( current_time );