Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed video reload on changing quality #159

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/components/QualitySelectorControllBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove the log?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the log.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hkirat can you review the code please?

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);
}
Expand Down