From cec2474295aec9463fe62b1df2a1fc66cf26e119 Mon Sep 17 00:00:00 2001 From: "Emilis (Idea IT)" <78907189+emilis-ideait@users.noreply.github.com> Date: Tue, 24 Aug 2021 15:24:50 +0300 Subject: [PATCH 1/7] Fixed errors when Plyr instance is destroyed before constructor setTimeout() functions execute. (#2108) Co-authored-by: Emilis Dambauskas --- src/js/captions.js | 4 +++- src/js/plyr.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/js/captions.js b/src/js/captions.js index 98d7d613..856baccf 100644 --- a/src/js/captions.js +++ b/src/js/captions.js @@ -154,7 +154,9 @@ const captions = { } // Enable or disable captions based on track length - toggleClass(this.elements.container, this.config.classNames.captions.enabled, !is.empty(tracks)); + if (this.elements) { + toggleClass(this.elements.container, this.config.classNames.captions.enabled, !is.empty(tracks)); + } // Update available languages in list if ( diff --git a/src/js/plyr.js b/src/js/plyr.js index b40f5c5a..3c3036ba 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -675,7 +675,9 @@ class Plyr { // Set media speed setTimeout(() => { - this.media.playbackRate = speed; + if (this.media) { + this.media.playbackRate = speed; + } }, 0); } From 02d06c464c3cb8dc978253667ec57b3437fe02de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Br=C3=A4ndewall?= Date: Tue, 24 Aug 2021 14:28:02 +0200 Subject: [PATCH 2/7] Fix invalid CSS selector syntax (#2303) https://jigsaw.w3.org/css-validator/ complains that "The selector :empty can't appear after the pseudo-element selector ::after". Switching their places, however, will validate. --- src/sass/plugins/ads.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sass/plugins/ads.scss b/src/sass/plugins/ads.scss index 16fb43e4..a1fe308b 100644 --- a/src/sass/plugins/ads.scss +++ b/src/sass/plugins/ads.scss @@ -36,7 +36,7 @@ z-index: 3; } - &::after:empty { + &:empty::after { display: none; } } From e4a18a5c995eafe111f4ed77cbd4147db8965ad8 Mon Sep 17 00:00:00 2001 From: Frosch Date: Wed, 29 Sep 2021 13:04:56 +0200 Subject: [PATCH 3/7] Vimeo private videos: check for hash in src and add as a param (#2322) * check for hash in src and add as a param * Enable different methods of passing hash --- src/js/config/defaults.js | 1 + src/js/plugins/vimeo.js | 42 +++++++++++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/js/config/defaults.js b/src/js/config/defaults.js index 7a73c318..e5e75e1c 100644 --- a/src/js/config/defaults.js +++ b/src/js/config/defaults.js @@ -398,6 +398,7 @@ const defaults = { embed: { provider: 'data-plyr-provider', id: 'data-plyr-embed-id', + hash: 'data-plyr-embed-hash', }, }, diff --git a/src/js/plugins/vimeo.js b/src/js/plugins/vimeo.js index 5fe41aba..e98c2ba5 100644 --- a/src/js/plugins/vimeo.js +++ b/src/js/plugins/vimeo.js @@ -28,6 +28,25 @@ function parseId(url) { return url.match(regex) ? RegExp.$2 : url; } +// Try to extract a hash for private videos from the URL +function parseHash(url) { + /* This regex matches a hexadecimal hash if given in any of these forms: + * - [https://player.]vimeo.com/video/{id}/{hash}[?params] + * - [https://player.]vimeo.com/video/{id}?h={hash}[¶ms] + * - [https://player.]vimeo.com/video/{id}?[params]&h={hash} + * - video/{id}/{hash} + * If matched, the hash is available in the named group `hash` + */ + const regex = /^.*(?:vimeo.com\/|video\/)(?:\d+)(?:\?.*\&*h=|\/)+(?[\d,a-f]+)/ + const found = url.match(regex) + + if (found) { + return found.groups.hash + } + + return null +} + // Set playback state and trigger change (only on actual change) function assurePlaybackState(play) { if (play && !this.embed.hasPlayed) { @@ -72,6 +91,19 @@ const vimeo = { const config = player.config.vimeo; const { premium, referrerPolicy, ...frameParams } = config; + // Get the source URL or ID + let source = player.media.getAttribute('src'); + let hash = '' + // Get from
if needed + if (is.empty(source)) { + source = player.media.getAttribute(player.config.attributes.embed.id); + // hash can also be set as attribute on the
+ hash = player.media.getAttribute(player.config.attributes.embed.hash); + } else { + hash = parseHash(source) + } + const hashParam = (!!hash) ? {h: hash} : {} + // If the owner has a pro or premium account then we can hide controls etc if (premium) { Object.assign(frameParams, { @@ -87,17 +119,11 @@ const vimeo = { muted: player.muted, gesture: 'media', playsinline: !this.config.fullscreen.iosNative, + // hash has to be added to iframe-URL + ...hashParam, ...frameParams, }); - // Get the source URL or ID - let source = player.media.getAttribute('src'); - - // Get from
if needed - if (is.empty(source)) { - source = player.media.getAttribute(player.config.attributes.embed.id); - } - const id = parseId(source); // Build an iframe const iframe = createElement('iframe'); From b4f24f90dad772ccce509aaed0ad6e06e2e03e96 Mon Sep 17 00:00:00 2001 From: Denis <32300784+liesahead@users.noreply.github.com> Date: Wed, 29 Sep 2021 14:08:12 +0300 Subject: [PATCH 4/7] (fix): youtube videos duration (ref #2223). (#2224) Co-authored-by: Denis Semionov --- src/js/ui.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/js/ui.js b/src/js/ui.js index c8b19677..9da2c781 100644 --- a/src/js/ui.js +++ b/src/js/ui.js @@ -82,6 +82,9 @@ const ui = { // Reset time display controls.timeUpdate.call(this); + // Reset duration display + controls.durationUpdate.call(this); + // Update the UI ui.checkPlaying.call(this); From d700bb9f02153565f8233f74e6d0a57acde5c75d Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Mon, 18 Apr 2022 11:36:55 +1000 Subject: [PATCH 5/7] chore: add cspell configuration --- cspell.json | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 cspell.json diff --git a/cspell.json b/cspell.json new file mode 100644 index 00000000..80286b43 --- /dev/null +++ b/cspell.json @@ -0,0 +1,24 @@ +{ + "version": "0.2", + "ignorePaths": [ + "package.json" + ], + "dictionaryDefinitions": [], + "dictionaries": [], + "words": [ + "autopause", + "autoplay", + "classname", + "fullscreen", + "gordita", + "menuitemradio", + "playsinline", + "plyr", + "seektime", + "srclang", + "stylelint", + "unmute" + ], + "ignoreWords": [], + "import": [] +} From 9157ac09ed3ecb4ef8011e53c82c49e25dd270a6 Mon Sep 17 00:00:00 2001 From: Will Herring <43892274+WilliamMHerring@users.noreply.github.com> Date: Sun, 17 Apr 2022 18:38:54 -0700 Subject: [PATCH 6/7] pass this context to captions.setup (#2399) Co-authored-by: Will Herring --- src/js/plyr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/plyr.js b/src/js/plyr.js index cad45d66..600eeba3 100644 --- a/src/js/plyr.js +++ b/src/js/plyr.js @@ -958,7 +958,7 @@ class Plyr { */ set currentTrack(input) { captions.set.call(this, input, false); - captions.setup(); + captions.setup.call(this); } /** From 895299a4b37d0217ca020afe79d23252f9a1ab70 Mon Sep 17 00:00:00 2001 From: Felix Klein Date: Mon, 18 Apr 2022 03:40:19 +0200 Subject: [PATCH 7/7] modify vimeo parseHash to use non-named capture groups (#2426) --- src/js/plugins/vimeo.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/js/plugins/vimeo.js b/src/js/plugins/vimeo.js index f20159f9..81238105 100644 --- a/src/js/plugins/vimeo.js +++ b/src/js/plugins/vimeo.js @@ -35,12 +35,12 @@ function parseHash(url) { * - [https://player.]vimeo.com/video/{id}?h={hash}[¶ms] * - [https://player.]vimeo.com/video/{id}?[params]&h={hash} * - video/{id}/{hash} - * If matched, the hash is available in the named group `hash` + * If matched, the hash is available in capture group 4 */ - const regex = /^.*(?:vimeo.com\/|video\/)(?:\d+)(?:\?.*&*h=|\/)+(?[\d,a-f]+)/; + const regex = /^.*(vimeo.com\/|video\/)(\d+)(\?.*&*h=|\/)+([\d,a-f]+)/; const found = url.match(regex); - return found ? found.groups.hash : null; + return found && found.length === 5 ? found[4] : null; } // Set playback state and trigger change (only on actual change)