From 4cc37c3f880814068f6dc9089e86f3eb9fc821fa Mon Sep 17 00:00:00 2001 From: Yunus Shaikh Date: Tue, 5 Mar 2024 22:22:20 +0530 Subject: [PATCH 1/2] fixed video reload on changing quality --- src/components/QualitySelectorControllBar.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/QualitySelectorControllBar.ts b/src/components/QualitySelectorControllBar.ts index 1109b9e3f..08edeaf34 100644 --- a/src/components/QualitySelectorControllBar.ts +++ b/src/components/QualitySelectorControllBar.ts @@ -6,6 +6,8 @@ const changeVideoQuality = (quality: string) => { window.location.href = currentUrl.href; }; +let quality: string = '1080'; + class QualitySelectorControllBar extends videojs.getComponent('Button') { constructor(player: any, options?: any) { super(player, options); @@ -41,14 +43,16 @@ class QualitySelectorControllBar extends videojs.getComponent('Button') { }); dropUpMenuElement.querySelectorAll('li').forEach((item) => { item.addEventListener('click', (e: any) => { - const quality = e.target.getAttribute('data-quality'); - if (quality) { + quality = e.target.getAttribute('data-quality'); + console.log(quality); + const currentUrl = new URL(window.location.href); + if (quality !== currentUrl.searchParams.get('quality')) { changeVideoQuality(quality); } dropUpMenuElement.style.display = 'none'; }); item.addEventListener('touchend', (e: any) => { - const quality = e.target.getAttribute('data-quality'); + quality = e.target.getAttribute('data-quality'); if (quality) { changeVideoQuality(quality); } From ec353880b48962524dfda5681aad417656a45ca6 Mon Sep 17 00:00:00 2001 From: Yunus Shaikh Date: Wed, 6 Mar 2024 21:12:15 +0530 Subject: [PATCH 2/2] removed log --- src/components/QualitySelectorControllBar.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/QualitySelectorControllBar.ts b/src/components/QualitySelectorControllBar.ts index 08edeaf34..c1ac15cd7 100644 --- a/src/components/QualitySelectorControllBar.ts +++ b/src/components/QualitySelectorControllBar.ts @@ -44,7 +44,6 @@ class QualitySelectorControllBar extends videojs.getComponent('Button') { dropUpMenuElement.querySelectorAll('li').forEach((item) => { item.addEventListener('click', (e: any) => { quality = e.target.getAttribute('data-quality'); - console.log(quality); const currentUrl = new URL(window.location.href); if (quality !== currentUrl.searchParams.get('quality')) { changeVideoQuality(quality);