From 97d9228bed639f0c20b1f21468dd3f181af6b262 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Mon, 3 Jun 2019 20:13:16 +1000 Subject: Aspect ratio tweaks --- src/js/html5.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/js/html5.js') diff --git a/src/js/html5.js b/src/js/html5.js index e538e922..b03e9c26 100644 --- a/src/js/html5.js +++ b/src/js/html5.js @@ -44,8 +44,10 @@ const html5 = { const player = this; - // Set aspect ratio if set - setAspectRatio.call(player); + // Set aspect ratio if fixed + if (!is.empty(this.config.ratio)) { + setAspectRatio.call(player); + } // Quality Object.defineProperty(player.media, 'quality', { -- cgit v1.2.3 From 6ffaef35cf667d0e2e14227882a1a8e329b2c2c2 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Tue, 14 Jan 2020 07:25:41 +0000 Subject: Manually merged PR #1607 --- src/js/html5.js | 70 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 30 deletions(-) (limited to 'src/js/html5.js') diff --git a/src/js/html5.js b/src/js/html5.js index b03e9c26..a0825cf6 100644 --- a/src/js/html5.js +++ b/src/js/html5.js @@ -30,6 +30,11 @@ const html5 = { // Get quality levels getQualityOptions() { + // Whether we're forcing all options (e.g. for streaming) + if (this.config.quality.forced) { + return this.config.quality.options; + } + // Get sizes from elements return html5.getSources .call(this) @@ -60,36 +65,41 @@ const html5 = { return source && Number(source.getAttribute('size')); }, set(input) { - // Get sources - const sources = html5.getSources.call(player); - // Get first match for requested size - const source = sources.find(s => Number(s.getAttribute('size')) === input); - - // No matching source found - if (!source) { - return; - } - - // Get current state - const { currentTime, paused, preload, readyState } = player.media; - - // Set new source - player.media.src = source.getAttribute('src'); - - // Prevent loading if preload="none" and the current source isn't loaded (#1044) - if (preload !== 'none' || readyState) { - // Restore time - player.once('loadedmetadata', () => { - player.currentTime = currentTime; - - // Resume playing - if (!paused) { - player.play(); - } - }); - - // Load new source - player.media.load(); + // If we're using an an external handler... + if (player.config.quality.forced && is.function(player.config.quality.onChange)) { + player.config.quality.onChange(input); + } else { + // Get sources + const sources = html5.getSources.call(player); + // Get first match for requested size + const source = sources.find(s => Number(s.getAttribute('size')) === input); + + // No matching source found + if (!source) { + return; + } + + // Get current state + const { currentTime, paused, preload, readyState } = player.media; + + // Set new source + player.media.src = source.getAttribute('src'); + + // Prevent loading if preload="none" and the current source isn't loaded (#1044) + if (preload !== 'none' || readyState) { + // Restore time + player.once('loadedmetadata', () => { + player.currentTime = currentTime; + + // Resume playing + if (!paused) { + player.play(); + } + }); + + // Load new source + player.media.load(); + } } // Trigger change event -- cgit v1.2.3 From 71d6f59d5619845aafe5c4414831e56d310700ff Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Tue, 21 Jan 2020 22:28:48 +0000 Subject: HTML5 poster fixes for multiple downloads --- src/js/html5.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/js/html5.js') diff --git a/src/js/html5.js b/src/js/html5.js index a0825cf6..1173bcbe 100644 --- a/src/js/html5.js +++ b/src/js/html5.js @@ -89,6 +89,10 @@ const html5 = { if (preload !== 'none' || readyState) { // Restore time player.once('loadedmetadata', () => { + if (player.currentTime === 0) { + return; + } + player.currentTime = currentTime; // Resume playing -- cgit v1.2.3 From 472bb479d478809df6afae3132a49cf009d874bb Mon Sep 17 00:00:00 2001 From: ydylla Date: Wed, 29 Jan 2020 23:03:43 +0100 Subject: fix regression: not restoring playback state after quality change --- src/js/html5.js | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/js/html5.js') diff --git a/src/js/html5.js b/src/js/html5.js index 1173bcbe..30d88ab0 100644 --- a/src/js/html5.js +++ b/src/js/html5.js @@ -89,9 +89,6 @@ const html5 = { if (preload !== 'none' || readyState) { // Restore time player.once('loadedmetadata', () => { - if (player.currentTime === 0) { - return; - } player.currentTime = currentTime; -- cgit v1.2.3 From f755a3c4012f24cd6025a0d268f4228958752093 Mon Sep 17 00:00:00 2001 From: ydylla Date: Fri, 31 Jan 2020 22:01:38 +0100 Subject: preserve playback rate at quality change --- src/js/html5.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/js/html5.js') diff --git a/src/js/html5.js b/src/js/html5.js index 30d88ab0..a28bccd5 100644 --- a/src/js/html5.js +++ b/src/js/html5.js @@ -80,7 +80,7 @@ const html5 = { } // Get current state - const { currentTime, paused, preload, readyState } = player.media; + const { currentTime, paused, preload, readyState, playbackRate } = player.media; // Set new source player.media.src = source.getAttribute('src'); @@ -90,6 +90,7 @@ const html5 = { // Restore time player.once('loadedmetadata', () => { + player.speed = playbackRate; player.currentTime = currentTime; // Resume playing -- cgit v1.2.3 From 0f08c7c13a62792fd4a6ae76b62e480bbdcc2c78 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Sat, 8 Feb 2020 21:48:51 +0000 Subject: Ignore quality change if it matches existing --- src/js/html5.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/js/html5.js') diff --git a/src/js/html5.js b/src/js/html5.js index 1173bcbe..0f76f453 100644 --- a/src/js/html5.js +++ b/src/js/html5.js @@ -65,6 +65,10 @@ const html5 = { return source && Number(source.getAttribute('size')); }, set(input) { + if (player.quality === input) { + return; + } + // If we're using an an external handler... if (player.config.quality.forced && is.function(player.config.quality.onChange)) { player.config.quality.onChange(input); -- cgit v1.2.3 From 1619510dcf9e3ccc1693caa20a173aaf2789e346 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Mon, 10 Feb 2020 18:34:05 +0000 Subject: Speed settings logic improvements --- src/js/html5.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/js/html5.js') diff --git a/src/js/html5.js b/src/js/html5.js index d1e82489..0591a709 100644 --- a/src/js/html5.js +++ b/src/js/html5.js @@ -42,13 +42,16 @@ const html5 = { .filter(Boolean); }, - extend() { + setup() { if (!this.isHTML5) { return; } const player = this; + // Set speed options from config + player.options.speed = player.config.speed.options; + // Set aspect ratio if fixed if (!is.empty(this.config.ratio)) { setAspectRatio.call(player); @@ -93,7 +96,6 @@ const html5 = { if (preload !== 'none' || readyState) { // Restore time player.once('loadedmetadata', () => { - player.speed = playbackRate; player.currentTime = currentTime; -- cgit v1.2.3 From 71928443f317e624ab94ff18e207447f06f745ad Mon Sep 17 00:00:00 2001 From: ydylla Date: Mon, 23 Mar 2020 22:50:19 +0100 Subject: silence all internal play promises --- src/js/html5.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/js/html5.js') diff --git a/src/js/html5.js b/src/js/html5.js index 0591a709..6e8c6483 100644 --- a/src/js/html5.js +++ b/src/js/html5.js @@ -6,6 +6,7 @@ import support from './support'; import { removeElement } from './utils/elements'; import { triggerEvent } from './utils/events'; import is from './utils/is'; +import { silencePromise } from './utils/promise'; import { setAspectRatio } from './utils/style'; const html5 = { @@ -101,7 +102,7 @@ const html5 = { // Resume playing if (!paused) { - player.play(); + silencePromise(player.play()); } }); -- cgit v1.2.3