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

fix: prevent other (e.g. website, extensions) scripts from receiving 'ratechange' event when switching to silenceSpeed? #87

Open
WofWca opened this issue Jul 14, 2022 · 0 comments

Comments

@WofWca
Copy link
Owner

WofWca commented Jul 14, 2022

You may say that It's kind of a non-normal thing that we switch to such high playback rate so maybe we shouldn't let other scripts notice that it's happening. Websites may watch 'ratechange' event and, for example, update user's website settings (playback rate), or something else.

Note that this is not the same as

case 'prevent': {
// Consider doing this for `defaultPlaybackRate` as well.
const lastPlaybackRateSetByUs = lastPlaybackRateSetByThisExtensionMap.get(el_);
if (
el_.playbackRate !== lastPlaybackRateSetByUs
// Just in case.
&& lastPlaybackRateSetByUs !== undefined
) {
setPlaybackRateAndRememberIt(el_, lastPlaybackRateSetByUs);
// The website may be listening to 'ratechange' events and update `playbackRate`
// inside the listener. Let's make it so that it doesn't receive the event.
// This happens on Twitch (https://github.com/WofWca/jumpcutter/issues/25).
event.stopImmediatePropagation();
}
break;
}

because there we .stopImmediatePropagation() for all ratechange events, not just for silenceSpeed.

It may help with compatibility with other playbackRate controlling extensions like "Video Speed Controller".

Not sure if we need this, need to know practical cases (besides maybe #25). Maybe make a per-site setting for this, idk.

To do this, look at event.stopPropagation( / event.stopImmediatePropagation( and related stuff.

Related #25

@WofWca WofWca changed the title fix: prevent other (e.g. website) scripts from receiving 'ratechange' event when switching to silenceSpeed? fix: prevent other (e.g. website, extensions) scripts from receiving 'ratechange' event when switching to silenceSpeed? Jul 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant